@burgan-tech/morph-touch-runtime 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/burgan-tech-morph-touch-runtime-0.0.2.tgz +0 -0
- package/package.json +21 -0
- package/touch/Extensions/.gitkeep +0 -0
- package/touch/Functions/.gitkeep +0 -0
- package/touch/Functions/check-livekit-room-access.1.0.0.json +28 -0
- package/touch/Functions/check-livekit-room-access.http +44 -0
- package/touch/Functions/get-absence-entry.1.0.0.json +28 -0
- package/touch/Functions/get-advisor-stats.1.0.0.json +27 -0
- package/touch/Functions/get-available-slots.1.0.0.json +30 -0
- package/touch/Functions/get-available-slots.http +29 -0
- package/touch/Functions/get-chat-rooms.1.0.0.json +28 -0
- package/touch/Functions/get-chat-rooms.http +62 -0
- package/touch/Functions/get-customer-info.1.0.0.json +27 -0
- package/touch/Functions/get-matrix-sync.1.0.0.json +28 -0
- package/touch/Functions/get-rezervations.1.0.0.json +26 -0
- package/touch/Functions/get-rezervations.http +59 -0
- package/touch/Functions/get-room-messages.1.0.0.json +29 -0
- package/touch/Functions/get-room-messages.http +45 -0
- package/touch/Functions/rezervation-transfer.http +118 -0
- package/touch/Functions/send-room-message.1.0.0.json +29 -0
- package/touch/Functions/src/CheckLivekitRoomAccessMapping.csx +238 -0
- package/touch/Functions/src/GetAbsenceEntryMapping.csx +225 -0
- package/touch/Functions/src/GetAdvisorStatsMapping.csx +190 -0
- package/touch/Functions/src/GetAvailableSlotsMapping.csx +468 -0
- package/touch/Functions/src/GetChatRoomsMapping.csx +202 -0
- package/touch/Functions/src/GetCustomerInfoMapping.csx +140 -0
- package/touch/Functions/src/GetMatrixSyncMapping.csx +197 -0
- package/touch/Functions/src/GetRezervationsMapping.csx +162 -0
- package/touch/Functions/src/GetRoomMessagesMapping.csx +165 -0
- package/touch/Functions/src/SendCancelNotificationMapping.csx +63 -0
- package/touch/Functions/src/SendRoomMessageMapping.csx +131 -0
- package/touch/Schemas/.gitkeep +0 -0
- package/touch/Schemas/absence-entry.1.0.0.json +232 -0
- package/touch/Schemas/advisor-chat-rooms.1.0.0.json +62 -0
- package/touch/Schemas/chat-room.1.0.0.json +110 -0
- package/touch/Schemas/notification-sender.1.0.0.json +159 -0
- package/touch/Schemas/portfolio-manager.1.0.0.json +63 -0
- package/touch/Schemas/rezervation.1.0.0.json +102 -0
- package/touch/Tasks/.gitkeep +0 -0
- package/touch/Tasks/cancel-absence-entry-for-rezervation.1.0.0.json +21 -0
- package/touch/Tasks/check-already-completed-chat-room.1.0.0.json +24 -0
- package/touch/Tasks/check-duplicate-portfolio-manager.1.0.0.json +23 -0
- package/touch/Tasks/check-duplicate-rezervation.1.0.0.json +23 -0
- package/touch/Tasks/check-existing-permanent-chat-room.1.0.0.json +21 -0
- package/touch/Tasks/check-randevu-time.1.0.0.json +17 -0
- package/touch/Tasks/create-permanent-chat-room.1.0.0.json +28 -0
- package/touch/Tasks/determine-transfer-type.1.0.0.json +16 -0
- package/touch/Tasks/enrich-rezervations-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/execute-permanent-chatroom-update.1.0.0.json +21 -0
- package/touch/Tasks/execute-rez-chatroom-transfer.1.0.0.json +21 -0
- package/touch/Tasks/execute-rezervation-transfer.1.0.0.json +19 -0
- package/touch/Tasks/fetch-absence-entries-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-advisors-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-permanent-chatrooms-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-rez-chatrooms-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-rezervations-for-transfer.1.0.0.json +22 -0
- package/touch/Tasks/get-absence-entry-task.1.0.0.json +23 -0
- package/touch/Tasks/get-available-slots-http.1.0.0.json +27 -0
- package/touch/Tasks/get-available-slots.1.0.0.json +24 -0
- package/touch/Tasks/get-chat-room-data-for-rezervation.1.0.0.json +23 -0
- package/touch/Tasks/get-chat-token.1.0.0.json +27 -0
- package/touch/Tasks/get-matrix-room-messages.1.0.0.json +25 -0
- package/touch/Tasks/get-matrix-sync.1.0.0.json +25 -0
- package/touch/Tasks/get-rezervation-data-task.1.0.0.json +22 -0
- package/touch/Tasks/get-rezervation-state-task.1.0.0.json +22 -0
- package/touch/Tasks/get-rezervations-task.1.0.0.json +21 -0
- package/touch/Tasks/get-user-info-for-rezervation.1.0.0.json +24 -0
- package/touch/Tasks/get-video-call-url.1.0.0.json +17 -0
- package/touch/Tasks/invite-user-to-rezervation-room.1.0.0.json +27 -0
- package/touch/Tasks/join-chat-room-for-rezervation.1.0.0.json +28 -0
- package/touch/Tasks/join-matrix-room.1.0.0.json +27 -0
- package/touch/Tasks/join-user-to-room.1.0.0.json +27 -0
- package/touch/Tasks/merge-invited-user.1.0.0.json +17 -0
- package/touch/Tasks/merge-rezervation-update.1.0.0.json +16 -0
- package/touch/Tasks/merge-target-advisor-for-transfer.1.0.0.json +17 -0
- package/touch/Tasks/merge-update-body-for-randevu-update.1.0.0.json +16 -0
- package/touch/Tasks/merge-video-call-urls.1.0.0.json +17 -0
- package/touch/Tasks/query-chat-room-instances.1.0.0.json +23 -0
- package/touch/Tasks/remove-member-from-room.1.0.0.json +28 -0
- package/touch/Tasks/send-matrix-room-message.1.0.0.json +26 -0
- package/touch/Tasks/send-push-notification.1.0.0.json +26 -0
- package/touch/Tasks/send-sms-notification.1.0.0.json +26 -0
- package/touch/Tasks/set-chat-room-status-active.1.0.0.json +16 -0
- package/touch/Tasks/set-chat-room-status-deactive.1.0.0.json +16 -0
- package/touch/Tasks/set-previous-advisor.1.0.0.json +16 -0
- package/touch/Tasks/set-user-from-headers-for-rezervation.1.0.0.json +17 -0
- package/touch/Tasks/start-absence-entry-for-rezervation.1.0.0.json +21 -0
- package/touch/Tasks/start-chat-room-for-rezervation.1.0.0.json +20 -0
- package/touch/Tasks/start-notification-sender.1.0.0.json +20 -0
- package/touch/Tasks/start-permanent-chat-room.1.0.0.json +21 -0
- package/touch/Tasks/start-transfer-from-absence-entry.1.0.0.json +19 -0
- package/touch/Tasks/start-video-call.1.0.0.json +22 -0
- package/touch/Tasks/trigger-chat-room-deactivate.1.0.0.json +21 -0
- package/touch/Tasks/trigger-chat-room-transfer.1.0.0.json +21 -0
- package/touch/Tasks/trigger-chat-room-update.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-add-invited-participant.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-apply-update.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-to-in-meet.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-video-call-update.1.0.0.json +21 -0
- package/touch/Tasks/validate-date-for-rezervation.1.0.0.json +18 -0
- package/touch/Tasks/validate-slot-for-rezervation.1.0.0.json +24 -0
- package/touch/Tasks/validate-transfer-availability.1.0.0.json +23 -0
- package/touch/Views/.gitkeep +0 -0
- package/touch/Workflows/.gitkeep +0 -0
- package/touch/Workflows/absence-entry.http +458 -0
- package/touch/Workflows/absence-entry.json +179 -0
- package/touch/Workflows/add-participant-to-rezervation.http +47 -0
- package/touch/Workflows/add-participant-to-rezervation.json +340 -0
- package/touch/Workflows/chat-room.http +207 -0
- package/touch/Workflows/chat-room.json +452 -0
- package/touch/Workflows/investment-advisor.json +367 -0
- package/touch/Workflows/notification-sender.http +299 -0
- package/touch/Workflows/notification-sender.json +262 -0
- package/touch/Workflows/portfolio-manager.json +367 -0
- package/touch/Workflows/randevu-update.http +87 -0
- package/touch/Workflows/rezervation-start.json +467 -0
- package/touch/Workflows/rezervation-transfer.json +512 -0
- package/touch/Workflows/rezervation-update.http +87 -0
- package/touch/Workflows/rezervation-update.json +485 -0
- package/touch/Workflows/rezervation.http +214 -0
- package/touch/Workflows/rezervation.json +726 -0
- package/touch/Workflows/src/AllChatRoomsSuccessRule.csx +65 -0
- package/touch/Workflows/src/AlwaysTrueRule.csx +13 -0
- package/touch/Workflows/src/AnyChatRoomFailedRule.csx +64 -0
- package/touch/Workflows/src/AutoProcessRule.csx +38 -0
- package/touch/Workflows/src/BuildRezChatRoomPlanMapping.csx +160 -0
- package/touch/Workflows/src/CanStartRezervationTimerMapping.csx +48 -0
- package/touch/Workflows/src/CanStartTransferMapping.csx +14 -0
- package/touch/Workflows/src/CancelAbsenceEntryForRezervationMapping.csx +48 -0
- package/touch/Workflows/src/CancelAbsenceForRandevuUpdateMapping.csx +62 -0
- package/touch/Workflows/src/ChatRoomCreatedFailedRule.csx +54 -0
- package/touch/Workflows/src/ChatRoomCreatedSuccessRule.csx +54 -0
- package/touch/Workflows/src/ChatRoomRemoveMapping.csx +104 -0
- package/touch/Workflows/src/ChatRoomTransferInviteMapping.csx +109 -0
- package/touch/Workflows/src/ChatRoomTransferRemoveMapping.csx +71 -0
- package/touch/Workflows/src/ChatRoomUpdateMapping.csx +107 -0
- package/touch/Workflows/src/CheckAlreadyCompletedChatRoomMapping.csx +100 -0
- package/touch/Workflows/src/CheckDuplicatePortfolioManagerMapping.csx +119 -0
- package/touch/Workflows/src/CheckDuplicateRezervationMapping.csx +150 -0
- package/touch/Workflows/src/CheckExistingPermanentChatRoomMapping.csx +169 -0
- package/touch/Workflows/src/CheckRandevuTimeMapping.csx +67 -0
- package/touch/Workflows/src/CheckRezervationStateActiveOrInMeetRule.csx +14 -0
- package/touch/Workflows/src/CreateAbsenceEntryForRezervationMapping.csx +111 -0
- package/touch/Workflows/src/CreateAbsenceForRandevuUpdateMapping.csx +108 -0
- package/touch/Workflows/src/CreateChatRoomForRezervationMapping.csx +122 -0
- package/touch/Workflows/src/CreatePermanentChatRoomMapping.csx +140 -0
- package/touch/Workflows/src/CustomerControlToEndRule.csx +14 -0
- package/touch/Workflows/src/DetermineTransferTypeMapping.csx +92 -0
- package/touch/Workflows/src/EnrichRezervationsForTransferMapping.csx +495 -0
- package/touch/Workflows/src/ExecutePermanentChatRoomUpdateMapping.csx +124 -0
- package/touch/Workflows/src/ExecuteRezChatRoomTransferMapping.csx +95 -0
- package/touch/Workflows/src/ExecuteTransferMapping.csx +152 -0
- package/touch/Workflows/src/FetchAbsenceEntriesForTransferMapping.csx +116 -0
- package/touch/Workflows/src/FetchAdvisorsForTransferMapping.csx +145 -0
- package/touch/Workflows/src/FetchPermanentChatRoomsMapping.csx +128 -0
- package/touch/Workflows/src/FetchRezervationsForTransferMapping.csx +124 -0
- package/touch/Workflows/src/GetChatRoomDataForRezervationMapping.csx +100 -0
- package/touch/Workflows/src/GetChatTokenMapping.csx +85 -0
- package/touch/Workflows/src/GetRezervationDataForAddParticipantMapping.csx +105 -0
- package/touch/Workflows/src/GetRezervationDataForRandevuUpdateMapping.csx +110 -0
- package/touch/Workflows/src/GetRezervationDataMapping.csx +111 -0
- package/touch/Workflows/src/GetRezervationStateForRandevuUpdateMapping.csx +80 -0
- package/touch/Workflows/src/GetRezervationStateMapping.csx +92 -0
- package/touch/Workflows/src/GetUserInfoForRezervationMapping.csx +63 -0
- package/touch/Workflows/src/GetVideoCallUrlMapping.csx +62 -0
- package/touch/Workflows/src/HasChangedAdvisorRule.csx +28 -0
- package/touch/Workflows/src/HasChatIntegrationRule.csx +41 -0
- package/touch/Workflows/src/HasExistingPermanentRoomRule.csx +28 -0
- package/touch/Workflows/src/InviteAdvisorForRandevuUpdateMapping.csx +86 -0
- package/touch/Workflows/src/InviteNewAdvisorToRezervationRoomMapping.csx +78 -0
- package/touch/Workflows/src/InviteNewParticipantToRandevuRoomMapping.csx +88 -0
- package/touch/Workflows/src/InvitedUserMergeMapping.csx +77 -0
- package/touch/Workflows/src/InvitedUserNotAllowedRule.csx +71 -0
- package/touch/Workflows/src/InvitedUserNotInMeetRule.csx +19 -0
- package/touch/Workflows/src/IsNotfSentRule.csx +36 -0
- package/touch/Workflows/src/JoinChatRoomForAddParticipantMapping.csx +118 -0
- package/touch/Workflows/src/JoinChatRoomForRandevuStartMapping.csx +119 -0
- package/touch/Workflows/src/JoinChatRoomForRezervationMapping.csx +118 -0
- package/touch/Workflows/src/JoinMatrixRoomMapping.csx +100 -0
- package/touch/Workflows/src/JoinUserToRoomMapping.csx +118 -0
- package/touch/Workflows/src/LoginForAddParticipantChatMapping.csx +102 -0
- package/touch/Workflows/src/LoginForRandevuStartChatMapping.csx +96 -0
- package/touch/Workflows/src/MergeRezervationUpdateMapping.csx +82 -0
- package/touch/Workflows/src/MergeTargetAdvisorForTransferMapping.csx +79 -0
- package/touch/Workflows/src/MergeUpdateBodyForRandevuUpdateMapping.csx +91 -0
- package/touch/Workflows/src/NoExistingPermanentRoomRule.csx +23 -0
- package/touch/Workflows/src/NotificationCompleteAlwaysRule.csx +14 -0
- package/touch/Workflows/src/NotificationCompleteFromPendingRule.csx +41 -0
- package/touch/Workflows/src/NotificationCompleteFromSmsRule.csx +36 -0
- package/touch/Workflows/src/NotificationPushFromPendingRule.csx +42 -0
- package/touch/Workflows/src/NotificationPushFromSmsRule.csx +36 -0
- package/touch/Workflows/src/NotificationSmsPendingRule.csx +32 -0
- package/touch/Workflows/src/PermanentDoneRule.csx +44 -0
- package/touch/Workflows/src/PermanentProcessNextRule.csx +44 -0
- package/touch/Workflows/src/RezChatRoomProcessNextRule.csx +44 -0
- package/touch/Workflows/src/RezChatRoomsDoneRule.csx +44 -0
- package/touch/Workflows/src/SendPushNotificationMapping.csx +146 -0
- package/touch/Workflows/src/SendSmsNotificationMapping.csx +138 -0
- package/touch/Workflows/src/SetChatRoomStatusActiveMapping.csx +22 -0
- package/touch/Workflows/src/SetChatRoomStatusDeactiveMapping.csx +22 -0
- package/touch/Workflows/src/SetPreviousAdvisorMapping.csx +28 -0
- package/touch/Workflows/src/SetUserFromHeadersForRezervationMapping.csx +24 -0
- package/touch/Workflows/src/SlotAvailableRule.csx +33 -0
- package/touch/Workflows/src/SlotUnavailableRule.csx +33 -0
- package/touch/Workflows/src/StartChatRoomForRezervationMapping.csx +100 -0
- package/touch/Workflows/src/StartGetChatTokenForRezervationMapping.csx +71 -0
- package/touch/Workflows/src/StartNotificationForAdvisorMapping.csx +117 -0
- package/touch/Workflows/src/StartNotificationForRezervationFromUserInfoMapping.csx +128 -0
- package/touch/Workflows/src/StartNotificationForUserMapping.csx +117 -0
- package/touch/Workflows/src/StartPermanentChatRoomMapping.csx +92 -0
- package/touch/Workflows/src/StartTransferFromAbsenceEntryMapping.csx +94 -0
- package/touch/Workflows/src/StartVideoCallCustomerSubFlowMapping.csx +37 -0
- package/touch/Workflows/src/StartVideoCallForInvitedParticipantMapping.csx +54 -0
- package/touch/Workflows/src/StartVideoCallForRandevuStartMapping.csx +70 -0
- package/touch/Workflows/src/StartVideoCallStaffSubFlowMapping.csx +37 -0
- package/touch/Workflows/src/StateActiveForUpdateRule.csx +14 -0
- package/touch/Workflows/src/StateActiveRule.csx +14 -0
- package/touch/Workflows/src/StateInMeetRule.csx +14 -0
- package/touch/Workflows/src/StateNotActiveForUpdateRule.csx +14 -0
- package/touch/Workflows/src/StateNotActiveOrInMeetRule.csx +14 -0
- package/touch/Workflows/src/StatusCustomerEnterRule.csx +25 -0
- package/touch/Workflows/src/StatusStaffEnterRule.csx +25 -0
- package/touch/Workflows/src/SyncWorkingHoursRule.csx +46 -0
- package/touch/Workflows/src/TokenSuccessRule.csx +24 -0
- package/touch/Workflows/src/TransferAllDoneRule.csx +50 -0
- package/touch/Workflows/src/TransferHasInvalidRule.csx +34 -0
- package/touch/Workflows/src/TransferProcessNextRule.csx +50 -0
- package/touch/Workflows/src/TriggerChatRoomDeactivateMapping.csx +77 -0
- package/touch/Workflows/src/TriggerChatRoomTransferMapping.csx +93 -0
- package/touch/Workflows/src/TriggerChatRoomUpdateMapping.csx +99 -0
- package/touch/Workflows/src/TriggerRezervationAddInvitedParticipantMapping.csx +77 -0
- package/touch/Workflows/src/TriggerRezervationApplyUpdateMapping.csx +66 -0
- package/touch/Workflows/src/TriggerRezervationToInMeetMapping.csx +69 -0
- package/touch/Workflows/src/TriggerRezervationVideoCallUpdateMapping.csx +67 -0
- package/touch/Workflows/src/ValidateDateForRezervationMapping.csx +60 -0
- package/touch/Workflows/src/ValidateSlotForRandevuUpdateMapping.csx +211 -0
- package/touch/Workflows/src/ValidateSlotForRezervationMapping.csx +246 -0
- package/touch/Workflows/src/ValidateTransferMapping.csx +243 -0
- package/touch/Workflows/src/VideoCallUrlUpdateMergeMapping.csx +141 -0
- package/touch/Workflows/start-chat.json +217 -0
- package/touch/Workflows/start-video-call.http +93 -0
- package/touch/Workflows/start-video-call.json +206 -0
- package/vnext.config.json +58 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
using BBT.Workflow.Scripting;
|
|
6
|
+
using BBT.Workflow.Definitions;
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for GetAbsenceEntryTask (DaprServiceTask - Type 3)
|
|
9
|
+
/// Queries absence-entry workflow instances in complete state, filtered by absenceType.
|
|
10
|
+
///
|
|
11
|
+
/// Query parameters:
|
|
12
|
+
/// - absenceType (required): "public-holiday" | "personal-leave" | "working-hours-change" | "rezervation"
|
|
13
|
+
/// - startDate (optional, public-holiday/personal-leave/rezervation): filter startDateTime >= value
|
|
14
|
+
/// - endDate (optional, public-holiday/personal-leave/rezervation): filter endDateTime <= value
|
|
15
|
+
/// - advisor (optional, personal-leave/working-hours-change/rezervation): filter by advisor
|
|
16
|
+
/// - pageSize (optional, default 100)
|
|
17
|
+
///
|
|
18
|
+
/// Note: Date filtering (startDate/endDate) is performed client-side in OutputHandler
|
|
19
|
+
/// because the platform API does not support gte/lte operators on attribute fields.
|
|
20
|
+
/// </summary>
|
|
21
|
+
public class GetAbsenceEntryMapping : ScriptBase, IMapping
|
|
22
|
+
{
|
|
23
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
24
|
+
{
|
|
25
|
+
var serviceTask = task as DaprServiceTask;
|
|
26
|
+
if (serviceTask == null)
|
|
27
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
28
|
+
|
|
29
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
30
|
+
if (!string.IsNullOrEmpty(appId))
|
|
31
|
+
serviceTask.SetAppId(appId);
|
|
32
|
+
|
|
33
|
+
var absenceType = ReadParam(context, "absenceType");
|
|
34
|
+
|
|
35
|
+
if (string.IsNullOrEmpty(absenceType))
|
|
36
|
+
{
|
|
37
|
+
return Task.FromResult(new ScriptResponse
|
|
38
|
+
{
|
|
39
|
+
Key = "validation-error",
|
|
40
|
+
Data = new
|
|
41
|
+
{
|
|
42
|
+
error = "absenceType is required",
|
|
43
|
+
errorCode = "VALIDATION_ERROR",
|
|
44
|
+
validValues = new[] { "public-holiday", "personal-leave", "working-hours-change", "rezervation" }
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var validTypes = new[] { "public-holiday", "personal-leave", "working-hours-change", "rezervation" };
|
|
50
|
+
bool isValid = false;
|
|
51
|
+
foreach (var vt in validTypes)
|
|
52
|
+
{
|
|
53
|
+
if (vt == absenceType) { isValid = true; break; }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!isValid)
|
|
57
|
+
{
|
|
58
|
+
return Task.FromResult(new ScriptResponse
|
|
59
|
+
{
|
|
60
|
+
Key = "validation-error",
|
|
61
|
+
Data = new
|
|
62
|
+
{
|
|
63
|
+
error = "Invalid absenceType value",
|
|
64
|
+
errorCode = "VALIDATION_ERROR",
|
|
65
|
+
provided = absenceType,
|
|
66
|
+
validValues = validTypes
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var advisor = ReadParam(context, "advisor");
|
|
72
|
+
|
|
73
|
+
var pageSizeStr = ReadParam(context, "pageSize");
|
|
74
|
+
int pageSize = 100;
|
|
75
|
+
if (!string.IsNullOrEmpty(pageSizeStr))
|
|
76
|
+
{
|
|
77
|
+
int parsed = 0;
|
|
78
|
+
if (int.TryParse(pageSizeStr, out parsed) && parsed > 0)
|
|
79
|
+
pageSize = parsed;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var conditions = new List<string>();
|
|
83
|
+
|
|
84
|
+
conditions.Add("{\"attributes\":{\"absenceType\":{\"eq\":\"" + absenceType + "\"}}}");
|
|
85
|
+
|
|
86
|
+
if (absenceType == "working-hours-change")
|
|
87
|
+
{
|
|
88
|
+
if (!string.IsNullOrEmpty(advisor))
|
|
89
|
+
conditions.Add("{\"key\":{\"eq\":\"working-hour-" + advisor + "\"}}");
|
|
90
|
+
else
|
|
91
|
+
conditions.Add("{\"key\":{\"eq\":\"working-hour\"}}");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if ((absenceType == "personal-leave" || absenceType == "rezervation") && !string.IsNullOrEmpty(advisor))
|
|
95
|
+
conditions.Add("{\"attributes\":{\"advisor\":{\"eq\":\"" + advisor + "\"}}}");
|
|
96
|
+
|
|
97
|
+
var filterJson = "{\"and\":[" + string.Join(",", conditions) + "]}";
|
|
98
|
+
|
|
99
|
+
var queryParams = new List<string>
|
|
100
|
+
{
|
|
101
|
+
"pageSize=" + pageSize,
|
|
102
|
+
"currentState=complete",
|
|
103
|
+
"filter=" + filterJson
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
serviceTask.SetQueryString(string.Join("&", queryParams));
|
|
107
|
+
|
|
108
|
+
return Task.FromResult(new ScriptResponse());
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
112
|
+
{
|
|
113
|
+
try
|
|
114
|
+
{
|
|
115
|
+
var absenceType = ReadParam(context, "absenceType");
|
|
116
|
+
var response = context.Body;
|
|
117
|
+
|
|
118
|
+
if (response?.isSuccess == false)
|
|
119
|
+
{
|
|
120
|
+
return new ScriptResponse
|
|
121
|
+
{
|
|
122
|
+
Key = "service-error",
|
|
123
|
+
Data = new
|
|
124
|
+
{
|
|
125
|
+
error = "Failed to fetch absence entries",
|
|
126
|
+
errorCode = "SERVICE_ERROR",
|
|
127
|
+
errorMessage = response?.errorMessage?.ToString(),
|
|
128
|
+
serviceInfo = new
|
|
129
|
+
{
|
|
130
|
+
appId = response?.metadata?.appId?.ToString(),
|
|
131
|
+
methodName = response?.metadata?.methodName?.ToString(),
|
|
132
|
+
httpVerb = response?.metadata?.httpVerb?.ToString()
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
Tags = new[] { "absence-entry", "error" }
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
var responseData = response?.data;
|
|
140
|
+
var items = responseData?.items;
|
|
141
|
+
|
|
142
|
+
bool supportsDateFilter = (absenceType == "public-holiday" || absenceType == "personal-leave" || absenceType == "rezervation");
|
|
143
|
+
var startDateStr = ReadParam(context, "startDate");
|
|
144
|
+
var endDateStr = ReadParam(context, "endDate");
|
|
145
|
+
|
|
146
|
+
if (supportsDateFilter && (!string.IsNullOrEmpty(startDateStr) || !string.IsNullOrEmpty(endDateStr)) && items != null)
|
|
147
|
+
{
|
|
148
|
+
DateTime startDateFilter = default;
|
|
149
|
+
DateTime endDateFilter = default;
|
|
150
|
+
bool hasStartFilter = !string.IsNullOrEmpty(startDateStr) && DateTime.TryParse(startDateStr, out startDateFilter);
|
|
151
|
+
bool hasEndFilter = !string.IsNullOrEmpty(endDateStr) && DateTime.TryParse(endDateStr, out endDateFilter);
|
|
152
|
+
|
|
153
|
+
var filteredItems = new List<dynamic>();
|
|
154
|
+
foreach (dynamic item in items)
|
|
155
|
+
{
|
|
156
|
+
var attrs = item?.attributes;
|
|
157
|
+
if (attrs == null) continue;
|
|
158
|
+
|
|
159
|
+
string itemStartStr = attrs?.startDateTime?.ToString();
|
|
160
|
+
string itemEndStr = attrs?.endDateTime?.ToString();
|
|
161
|
+
|
|
162
|
+
DateTime itemStart = default;
|
|
163
|
+
DateTime itemEnd = default;
|
|
164
|
+
bool parsedStart = !string.IsNullOrEmpty(itemStartStr) && DateTime.TryParse(itemStartStr, out itemStart);
|
|
165
|
+
bool parsedEnd = !string.IsNullOrEmpty(itemEndStr) && DateTime.TryParse(itemEndStr, out itemEnd);
|
|
166
|
+
|
|
167
|
+
bool include = true;
|
|
168
|
+
|
|
169
|
+
if (hasStartFilter && parsedStart && itemStart < startDateFilter)
|
|
170
|
+
include = false;
|
|
171
|
+
|
|
172
|
+
if (hasEndFilter && parsedEnd && itemEnd > endDateFilter)
|
|
173
|
+
include = false;
|
|
174
|
+
|
|
175
|
+
if (include)
|
|
176
|
+
filteredItems.Add(item);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return new ScriptResponse
|
|
180
|
+
{
|
|
181
|
+
Key = "absence-entry-success",
|
|
182
|
+
Data = new
|
|
183
|
+
{
|
|
184
|
+
absenceType,
|
|
185
|
+
items = filteredItems
|
|
186
|
+
},
|
|
187
|
+
Tags = new string[] { "absence-entry", absenceType ?? "", "success" }
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return new ScriptResponse
|
|
192
|
+
{
|
|
193
|
+
Key = "absence-entry-success",
|
|
194
|
+
Data = new
|
|
195
|
+
{
|
|
196
|
+
absenceType,
|
|
197
|
+
items
|
|
198
|
+
},
|
|
199
|
+
Tags = new string[] { "absence-entry", absenceType ?? "", "success" }
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
catch (Exception ex)
|
|
203
|
+
{
|
|
204
|
+
return new ScriptResponse
|
|
205
|
+
{
|
|
206
|
+
Key = "output-error",
|
|
207
|
+
Data = new
|
|
208
|
+
{
|
|
209
|
+
error = "Internal processing error",
|
|
210
|
+
errorCode = "PROCESSING_ERROR",
|
|
211
|
+
errorDescription = ex.Message
|
|
212
|
+
},
|
|
213
|
+
Tags = new[] { "absence-entry", "error" }
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
private string ReadParam(ScriptContext context, string name)
|
|
219
|
+
{
|
|
220
|
+
if (context.QueryParameters == null || !HasProperty(context.QueryParameters, name))
|
|
221
|
+
return null;
|
|
222
|
+
var val = context.QueryParameters[name];
|
|
223
|
+
return val != null ? val.ToString() : null;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
using BBT.Workflow.Scripting;
|
|
6
|
+
using BBT.Workflow.Definitions;
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for GetAdvisorStatsTask (DaprServiceTask - Type 3)
|
|
9
|
+
/// Queries rezervation workflow instances to calculate advisor performance statistics.
|
|
10
|
+
///
|
|
11
|
+
/// Query parameters:
|
|
12
|
+
/// - advisorId (required): advisor identifier
|
|
13
|
+
/// - period (optional): "week" | "month" — default "week"
|
|
14
|
+
/// - startDate (optional): filter startDateTime >= value
|
|
15
|
+
/// - endDate (optional): filter endDateTime <= value
|
|
16
|
+
/// </summary>
|
|
17
|
+
public class GetAdvisorStatsMapping : ScriptBase, IMapping
|
|
18
|
+
{
|
|
19
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
20
|
+
{
|
|
21
|
+
var serviceTask = task as DaprServiceTask;
|
|
22
|
+
if (serviceTask == null)
|
|
23
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
24
|
+
|
|
25
|
+
var advisorId = ReadParam(context, "advisorId");
|
|
26
|
+
if (string.IsNullOrEmpty(advisorId))
|
|
27
|
+
{
|
|
28
|
+
return Task.FromResult(new ScriptResponse
|
|
29
|
+
{
|
|
30
|
+
Key = "validation-error",
|
|
31
|
+
Data = new
|
|
32
|
+
{
|
|
33
|
+
error = "advisorId is required",
|
|
34
|
+
errorCode = "VALIDATION_ERROR"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var period = ReadParam(context, "period") ?? "week";
|
|
40
|
+
var startDate = ReadParam(context, "startDate");
|
|
41
|
+
var endDate = ReadParam(context, "endDate");
|
|
42
|
+
|
|
43
|
+
if (string.IsNullOrEmpty(startDate) || string.IsNullOrEmpty(endDate))
|
|
44
|
+
{
|
|
45
|
+
var now = DateTime.UtcNow;
|
|
46
|
+
if (period == "month")
|
|
47
|
+
{
|
|
48
|
+
startDate = startDate ?? now.AddDays(-30).ToString("yyyy-MM-ddTHH:mm:ss");
|
|
49
|
+
endDate = endDate ?? now.ToString("yyyy-MM-ddTHH:mm:ss");
|
|
50
|
+
}
|
|
51
|
+
else
|
|
52
|
+
{
|
|
53
|
+
startDate = startDate ?? now.AddDays(-7).ToString("yyyy-MM-ddTHH:mm:ss");
|
|
54
|
+
endDate = endDate ?? now.ToString("yyyy-MM-ddTHH:mm:ss");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var conditions = new List<string>();
|
|
59
|
+
conditions.Add("{\"attributes\":{\"advisor\":{\"eq\":\"" + advisorId + "\"}}}");
|
|
60
|
+
conditions.Add("{\"status\":{\"eq\":\"A\"}}");
|
|
61
|
+
|
|
62
|
+
var filterJson = "{\"and\":[" + string.Join(",", conditions) + "]}";
|
|
63
|
+
|
|
64
|
+
var queryParams = new List<string>{
|
|
65
|
+
"pageSize=500",
|
|
66
|
+
$"filter={filterJson}"
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
serviceTask.SetQueryString(string.Join("&", queryParams));
|
|
70
|
+
return Task.FromResult(new ScriptResponse());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
74
|
+
{
|
|
75
|
+
try
|
|
76
|
+
{
|
|
77
|
+
var advisorId = ReadParam(context, "advisorId");
|
|
78
|
+
var period = ReadParam(context, "period") ?? "week";
|
|
79
|
+
var startDate = ReadParam(context, "startDate");
|
|
80
|
+
var endDate = ReadParam(context, "endDate");
|
|
81
|
+
|
|
82
|
+
var response = context.Body;
|
|
83
|
+
|
|
84
|
+
if (response?.isSuccess == false)
|
|
85
|
+
{
|
|
86
|
+
return Task.FromResult(new ScriptResponse
|
|
87
|
+
{
|
|
88
|
+
Key = "service-error",
|
|
89
|
+
Data = new
|
|
90
|
+
{
|
|
91
|
+
error = "Failed to fetch reservations for stats",
|
|
92
|
+
errorCode = "SERVICE_ERROR",
|
|
93
|
+
errorMessage = response?.errorMessage?.ToString()
|
|
94
|
+
},
|
|
95
|
+
Tags = new[] { "advisor-stats", "error" }
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var responseData = response?.data;
|
|
100
|
+
var items = responseData?.items;
|
|
101
|
+
|
|
102
|
+
int totalCount = 0;
|
|
103
|
+
int completedCount = 0;
|
|
104
|
+
int cancelledCount = 0;
|
|
105
|
+
int activeCount = 0;
|
|
106
|
+
int inMeetCount = 0;
|
|
107
|
+
double totalDurationMinutes = 0;
|
|
108
|
+
|
|
109
|
+
DateTime filterStart = DateTime.MinValue;
|
|
110
|
+
DateTime filterEnd = DateTime.MaxValue;
|
|
111
|
+
if (!string.IsNullOrEmpty(startDate)) DateTime.TryParse(startDate, out filterStart);
|
|
112
|
+
if (!string.IsNullOrEmpty(endDate)) DateTime.TryParse(endDate, out filterEnd);
|
|
113
|
+
|
|
114
|
+
if (items != null)
|
|
115
|
+
{
|
|
116
|
+
foreach (dynamic item in items)
|
|
117
|
+
{
|
|
118
|
+
var attrs = item?.attributes;
|
|
119
|
+
if (attrs == null) continue;
|
|
120
|
+
|
|
121
|
+
string itemStartStr = attrs?.startDateTime?.ToString();
|
|
122
|
+
if (string.IsNullOrEmpty(itemStartStr)) continue;
|
|
123
|
+
|
|
124
|
+
DateTime itemStart;
|
|
125
|
+
if (!DateTime.TryParse(itemStartStr, out itemStart)) continue;
|
|
126
|
+
|
|
127
|
+
if (itemStart < filterStart || itemStart > filterEnd) continue;
|
|
128
|
+
|
|
129
|
+
totalCount++;
|
|
130
|
+
|
|
131
|
+
string state = item?.metadata?.currentState?.ToString() ?? "";
|
|
132
|
+
if (state == "meet-completed" || state == "completed") completedCount++;
|
|
133
|
+
else if (state == "user-cancelled" || state == "advisor-cancelled" || state == "timeout") cancelledCount++;
|
|
134
|
+
else if (state == "active" || state == "can-start-meeting" || state == "accept-terms") activeCount++;
|
|
135
|
+
else if (state == "in-meet") inMeetCount++;
|
|
136
|
+
|
|
137
|
+
string itemEndStr = attrs?.endDateTime?.ToString();
|
|
138
|
+
if (!string.IsNullOrEmpty(itemEndStr))
|
|
139
|
+
{
|
|
140
|
+
DateTime itemEnd;
|
|
141
|
+
if (DateTime.TryParse(itemEndStr, out itemEnd))
|
|
142
|
+
totalDurationMinutes += (itemEnd - itemStart).TotalMinutes;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return Task.FromResult(new ScriptResponse
|
|
148
|
+
{
|
|
149
|
+
Key = "advisor-stats-success",
|
|
150
|
+
Data = new
|
|
151
|
+
{
|
|
152
|
+
advisorId,
|
|
153
|
+
period,
|
|
154
|
+
startDate,
|
|
155
|
+
endDate,
|
|
156
|
+
totalReservations = totalCount,
|
|
157
|
+
completed = completedCount,
|
|
158
|
+
cancelled = cancelledCount,
|
|
159
|
+
active = activeCount,
|
|
160
|
+
inMeet = inMeetCount,
|
|
161
|
+
averageDurationMinutes = totalCount > 0 ? Math.Round(totalDurationMinutes / totalCount, 1) : 0,
|
|
162
|
+
totalDurationMinutes = Math.Round(totalDurationMinutes, 1)
|
|
163
|
+
},
|
|
164
|
+
Tags = new[] { "advisor-stats", "success" }
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
catch (Exception ex)
|
|
168
|
+
{
|
|
169
|
+
return Task.FromResult(new ScriptResponse
|
|
170
|
+
{
|
|
171
|
+
Key = "output-error",
|
|
172
|
+
Data = new
|
|
173
|
+
{
|
|
174
|
+
error = "Internal processing error",
|
|
175
|
+
errorCode = "PROCESSING_ERROR",
|
|
176
|
+
errorDescription = ex.Message
|
|
177
|
+
},
|
|
178
|
+
Tags = new[] { "advisor-stats", "error" }
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private string ReadParam(ScriptContext context, string name)
|
|
184
|
+
{
|
|
185
|
+
if (context.QueryParameters == null || !HasProperty(context.QueryParameters, name))
|
|
186
|
+
return null;
|
|
187
|
+
var val = context.QueryParameters[name];
|
|
188
|
+
return val != null ? val.ToString() : null;
|
|
189
|
+
}
|
|
190
|
+
}
|