@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,77 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for trigger-chat-room-deactivate DirectTriggerTask.
|
|
9
|
+
/// Triggers deactivate transition on chat-room instance. Uses existingChatRoomInstanceKey from start-chat instance data.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class TriggerChatRoomDeactivateMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
var triggerTask = task as DirectTriggerTask;
|
|
16
|
+
if (triggerTask == null)
|
|
17
|
+
throw new InvalidOperationException("Task must be a DirectTriggerTask");
|
|
18
|
+
|
|
19
|
+
var data = context.Instance?.Data;
|
|
20
|
+
var existingChatRoomInstanceKey = GetString(data, "existingChatRoomInstanceKey");
|
|
21
|
+
|
|
22
|
+
if (string.IsNullOrWhiteSpace(existingChatRoomInstanceKey))
|
|
23
|
+
{
|
|
24
|
+
return Task.FromResult(new ScriptResponse
|
|
25
|
+
{
|
|
26
|
+
Key = "chat-room-deactivate-skipped",
|
|
27
|
+
Data = new Dictionary<string, object>
|
|
28
|
+
{
|
|
29
|
+
{ "deactivateTriggered", false },
|
|
30
|
+
{ "reason", "missing-existingChatRoomInstanceKey" }
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
triggerTask.SetDomain("touch");
|
|
36
|
+
triggerTask.SetFlow("chat-room");
|
|
37
|
+
triggerTask.SetKey(existingChatRoomInstanceKey.Trim());
|
|
38
|
+
triggerTask.SetTransitionName("deactivate");
|
|
39
|
+
triggerTask.SetBody(new Dictionary<string, object>());
|
|
40
|
+
|
|
41
|
+
return Task.FromResult(new ScriptResponse
|
|
42
|
+
{
|
|
43
|
+
Data = new Dictionary<string, object> { { "deactivateTriggered", true } }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
48
|
+
{
|
|
49
|
+
if (context.Body?.isSuccess != true)
|
|
50
|
+
{
|
|
51
|
+
return Task.FromResult(new ScriptResponse
|
|
52
|
+
{
|
|
53
|
+
Key = "chat-room-deactivate-failed",
|
|
54
|
+
Data = new
|
|
55
|
+
{
|
|
56
|
+
error = context.Body?.errorMessage?.ToString() ?? "Chat room deactivate failed"
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return Task.FromResult(new ScriptResponse());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private string GetString(dynamic obj, string name)
|
|
64
|
+
{
|
|
65
|
+
if (obj == null) return null;
|
|
66
|
+
try
|
|
67
|
+
{
|
|
68
|
+
if (HasProperty(obj, name))
|
|
69
|
+
{
|
|
70
|
+
var v = GetPropertyValue(obj, name);
|
|
71
|
+
return v?.ToString()?.Trim();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for trigger-chat-room-transfer DirectTriggerTask.
|
|
9
|
+
/// Triggers transfer transition on chat-room instance. Uses existingChatRoomInstanceKey and newAdvisorId from start-chat instance data.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class TriggerChatRoomTransferMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
var triggerTask = task as DirectTriggerTask;
|
|
16
|
+
if (triggerTask == null)
|
|
17
|
+
throw new InvalidOperationException("Task must be a DirectTriggerTask");
|
|
18
|
+
|
|
19
|
+
var data = context.Instance?.Data;
|
|
20
|
+
var existingChatRoomInstanceKey = GetString(data, "existingChatRoomInstanceKey");
|
|
21
|
+
var newAdvisorId = GetString(data, "advisorId");
|
|
22
|
+
|
|
23
|
+
if (string.IsNullOrWhiteSpace(existingChatRoomInstanceKey))
|
|
24
|
+
{
|
|
25
|
+
return Task.FromResult(new ScriptResponse
|
|
26
|
+
{
|
|
27
|
+
Key = "chat-room-transfer-skipped",
|
|
28
|
+
Data = new Dictionary<string, object>
|
|
29
|
+
{
|
|
30
|
+
{ "transferTriggered", false },
|
|
31
|
+
{ "reason", "missing-existingChatRoomInstanceKey" }
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (string.IsNullOrWhiteSpace(newAdvisorId))
|
|
36
|
+
{
|
|
37
|
+
return Task.FromResult(new ScriptResponse
|
|
38
|
+
{
|
|
39
|
+
Key = "chat-room-transfer-skipped",
|
|
40
|
+
Data = new Dictionary<string, object>
|
|
41
|
+
{
|
|
42
|
+
{ "transferTriggered", false },
|
|
43
|
+
{ "reason", "missing-newAdvisorId" }
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
triggerTask.SetDomain("touch");
|
|
49
|
+
triggerTask.SetFlow("chat-room");
|
|
50
|
+
triggerTask.SetKey(existingChatRoomInstanceKey.Trim());
|
|
51
|
+
triggerTask.SetTransitionName("transfer");
|
|
52
|
+
triggerTask.SetBody(new Dictionary<string, object>
|
|
53
|
+
{
|
|
54
|
+
{ "newAdvisorId", newAdvisorId.Trim() }
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return Task.FromResult(new ScriptResponse
|
|
58
|
+
{
|
|
59
|
+
Data = new Dictionary<string, object> { { "transferTriggered", true } }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
64
|
+
{
|
|
65
|
+
if (context.Body?.isSuccess != true)
|
|
66
|
+
{
|
|
67
|
+
return Task.FromResult(new ScriptResponse
|
|
68
|
+
{
|
|
69
|
+
Key = "chat-room-transfer-failed",
|
|
70
|
+
Data = new
|
|
71
|
+
{
|
|
72
|
+
error = context.Body?.errorMessage?.ToString() ?? "Chat room transfer failed"
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return Task.FromResult(new ScriptResponse());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private string GetString(dynamic obj, string name)
|
|
80
|
+
{
|
|
81
|
+
if (obj == null) return null;
|
|
82
|
+
try
|
|
83
|
+
{
|
|
84
|
+
if (HasProperty(obj, name))
|
|
85
|
+
{
|
|
86
|
+
var v = GetPropertyValue(obj, name);
|
|
87
|
+
return v?.ToString()?.Trim();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch { }
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for trigger-chat-room-update DirectTriggerTask.
|
|
9
|
+
/// Triggers update transition on chat-room instance (add member). Key = rezervation-chat-{NormalizeForKey(randevuKey)}, Body = { newMemberId }.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class TriggerChatRoomUpdateMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
var triggerTask = task as DirectTriggerTask;
|
|
16
|
+
if (triggerTask == null)
|
|
17
|
+
throw new InvalidOperationException("Task must be a DirectTriggerTask");
|
|
18
|
+
|
|
19
|
+
var data = context.Instance?.Data;
|
|
20
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
21
|
+
var newUserId = GetString(data, "newUserId");
|
|
22
|
+
if (string.IsNullOrWhiteSpace(randevuKey))
|
|
23
|
+
{
|
|
24
|
+
return Task.FromResult(new ScriptResponse
|
|
25
|
+
{
|
|
26
|
+
Key = "chat-room-update-skipped",
|
|
27
|
+
Data = new Dictionary<string, object>
|
|
28
|
+
{
|
|
29
|
+
{ "updateTriggered", false },
|
|
30
|
+
{ "reason", "missing-randevuKey" }
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (string.IsNullOrWhiteSpace(newUserId))
|
|
35
|
+
{
|
|
36
|
+
return Task.FromResult(new ScriptResponse
|
|
37
|
+
{
|
|
38
|
+
Key = "chat-room-update-skipped",
|
|
39
|
+
Data = new Dictionary<string, object>
|
|
40
|
+
{
|
|
41
|
+
{ "updateTriggered", false },
|
|
42
|
+
{ "reason", "missing-newUserId" }
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var chatRoomKey = "rezervation-chat-" + NormalizeForKey(randevuKey);
|
|
48
|
+
triggerTask.SetDomain("touch");
|
|
49
|
+
triggerTask.SetFlow("chat-room");
|
|
50
|
+
triggerTask.SetKey(chatRoomKey);
|
|
51
|
+
triggerTask.SetTransitionName("update");
|
|
52
|
+
triggerTask.SetBody(new Dictionary<string, object>
|
|
53
|
+
{
|
|
54
|
+
{ "newMemberId", newUserId.Trim() }
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return Task.FromResult(new ScriptResponse
|
|
58
|
+
{
|
|
59
|
+
Data = new Dictionary<string, object> { { "updateTriggered", true } }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
64
|
+
{
|
|
65
|
+
if (context.Body?.isSuccess != true)
|
|
66
|
+
{
|
|
67
|
+
return Task.FromResult(new ScriptResponse
|
|
68
|
+
{
|
|
69
|
+
Key = "chat-room-update-failed",
|
|
70
|
+
Data = new
|
|
71
|
+
{
|
|
72
|
+
error = context.Body?.errorMessage?.ToString() ?? "Chat room update failed"
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return Task.FromResult(new ScriptResponse());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private static string NormalizeForKey(string value)
|
|
80
|
+
{
|
|
81
|
+
if (string.IsNullOrEmpty(value)) return value ?? "";
|
|
82
|
+
return value.Replace(":", "-").Replace(" ", "-");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private string GetString(dynamic obj, string name)
|
|
86
|
+
{
|
|
87
|
+
if (obj == null) return null;
|
|
88
|
+
try
|
|
89
|
+
{
|
|
90
|
+
if (HasProperty(obj, name))
|
|
91
|
+
{
|
|
92
|
+
var v = GetPropertyValue(obj, name);
|
|
93
|
+
return v?.ToString()?.Trim();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch { }
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for trigger-rezervation-add-invited-participant DirectTriggerTask.
|
|
9
|
+
/// Triggers add-invited-participant transition on rezervation instance.
|
|
10
|
+
/// Key = randevuKey, Body = { invitedUserId }.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class TriggerRezervationAddInvitedParticipantMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var triggerTask = task as DirectTriggerTask;
|
|
17
|
+
if (triggerTask == null)
|
|
18
|
+
throw new InvalidOperationException("Task must be a DirectTriggerTask");
|
|
19
|
+
|
|
20
|
+
var data = context.Instance?.Data;
|
|
21
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
22
|
+
var newUserId = GetString(data, "newUserId");
|
|
23
|
+
if (string.IsNullOrWhiteSpace(randevuKey))
|
|
24
|
+
{
|
|
25
|
+
return Task.FromResult(new ScriptResponse
|
|
26
|
+
{
|
|
27
|
+
Data = new Dictionary<string, object>
|
|
28
|
+
{
|
|
29
|
+
{ "updateTriggered", false },
|
|
30
|
+
{ "reason", "missing-randevuKey" }
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (string.IsNullOrWhiteSpace(newUserId))
|
|
35
|
+
{
|
|
36
|
+
return Task.FromResult(new ScriptResponse
|
|
37
|
+
{
|
|
38
|
+
Data = new Dictionary<string, object>
|
|
39
|
+
{
|
|
40
|
+
{ "updateTriggered", false },
|
|
41
|
+
{ "reason", "missing-newUserId" }
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
triggerTask.SetDomain("touch");
|
|
47
|
+
triggerTask.SetFlow("rezervation");
|
|
48
|
+
triggerTask.SetKey(randevuKey);
|
|
49
|
+
triggerTask.SetTransitionName("add-invited-participant");
|
|
50
|
+
triggerTask.SetBody(new Dictionary<string, object> { { "invitedUserId", newUserId.Trim() } });
|
|
51
|
+
|
|
52
|
+
return Task.FromResult(new ScriptResponse
|
|
53
|
+
{
|
|
54
|
+
Data = new Dictionary<string, object> { { "updateTriggered", true } }
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
59
|
+
{
|
|
60
|
+
return Task.FromResult(new ScriptResponse());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private string GetString(dynamic obj, string name)
|
|
64
|
+
{
|
|
65
|
+
if (obj == null) return null;
|
|
66
|
+
try
|
|
67
|
+
{
|
|
68
|
+
if (HasProperty(obj, name))
|
|
69
|
+
{
|
|
70
|
+
var v = GetPropertyValue(obj, name);
|
|
71
|
+
return v?.ToString();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for trigger-rezervation-apply-update DirectTriggerTask.
|
|
8
|
+
/// Triggers apply-update transition on rezervation instance with merged data.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class TriggerRezervationApplyUpdateMapping : ScriptBase, IMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
var triggerTask = task as DirectTriggerTask;
|
|
15
|
+
if (triggerTask == null)
|
|
16
|
+
throw new InvalidOperationException("Task must be a DirectTriggerTask");
|
|
17
|
+
|
|
18
|
+
var data = context.Instance?.Data;
|
|
19
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
20
|
+
if (string.IsNullOrWhiteSpace(randevuKey))
|
|
21
|
+
throw new InvalidOperationException("randevuKey is required");
|
|
22
|
+
|
|
23
|
+
var startDateTime = GetString(data, "startDateTime");
|
|
24
|
+
var endDateTime = GetString(data, "endDateTime");
|
|
25
|
+
var advisor = GetString(data, "advisor");
|
|
26
|
+
var absenceEntryKey = GetString(data, "absenceEntryKey");
|
|
27
|
+
var originalAdvisor = GetString(data, "originalAdvisor");
|
|
28
|
+
|
|
29
|
+
triggerTask.SetDomain("touch");
|
|
30
|
+
triggerTask.SetFlow("rezervation");
|
|
31
|
+
triggerTask.SetKey(randevuKey);
|
|
32
|
+
triggerTask.SetTransitionName("apply-update");
|
|
33
|
+
triggerTask.SetSync(true);
|
|
34
|
+
|
|
35
|
+
var body = new Dictionary<string, object>();
|
|
36
|
+
if (!string.IsNullOrEmpty(startDateTime)) body["startDateTime"] = startDateTime;
|
|
37
|
+
if (!string.IsNullOrEmpty(endDateTime)) body["endDateTime"] = endDateTime;
|
|
38
|
+
if (!string.IsNullOrEmpty(advisor)) body["advisor"] = advisor;
|
|
39
|
+
if (!string.IsNullOrEmpty(absenceEntryKey)) body["absenceEntryKey"] = absenceEntryKey;
|
|
40
|
+
if (!string.IsNullOrEmpty(originalAdvisor)) body["previousAdvisor"] = originalAdvisor;
|
|
41
|
+
|
|
42
|
+
triggerTask.SetBody(body);
|
|
43
|
+
|
|
44
|
+
return Task.FromResult(new ScriptResponse());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
48
|
+
{
|
|
49
|
+
return Task.FromResult(new ScriptResponse());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private string GetString(dynamic obj, string name)
|
|
53
|
+
{
|
|
54
|
+
if (obj == null) return null;
|
|
55
|
+
try
|
|
56
|
+
{
|
|
57
|
+
if (HasProperty(obj, name))
|
|
58
|
+
{
|
|
59
|
+
var v = GetPropertyValue(obj, name);
|
|
60
|
+
return v?.ToString();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch { }
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for trigger-rezervation-to-in-meet DirectTriggerTask.
|
|
8
|
+
/// Triggers to-in-meet transition on rezervation instance. SetKey(randevuKey), SetBody(attributes merge).
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class TriggerRezervationToInMeetMapping : ScriptBase, IMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
var triggerTask = task as DirectTriggerTask;
|
|
15
|
+
if (triggerTask == null)
|
|
16
|
+
throw new InvalidOperationException("Task must be a DirectTriggerTask");
|
|
17
|
+
|
|
18
|
+
var data = context.Instance?.Data;
|
|
19
|
+
var randevuKey = GetString(data, "randevuKey");
|
|
20
|
+
if (string.IsNullOrWhiteSpace(randevuKey))
|
|
21
|
+
throw new InvalidOperationException("randevuKey is required");
|
|
22
|
+
|
|
23
|
+
triggerTask.SetDomain("touch");
|
|
24
|
+
triggerTask.SetFlow("rezervation");
|
|
25
|
+
triggerTask.SetKey(randevuKey);
|
|
26
|
+
triggerTask.SetTransitionName("to-in-meet");
|
|
27
|
+
triggerTask.SetSync(true);
|
|
28
|
+
var chatIntegration = GetValue(data, "chatIntegration");
|
|
29
|
+
var body = new
|
|
30
|
+
{
|
|
31
|
+
chatIntegration
|
|
32
|
+
};
|
|
33
|
+
triggerTask.SetBody(body);
|
|
34
|
+
|
|
35
|
+
return Task.FromResult(new ScriptResponse());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
39
|
+
{
|
|
40
|
+
return Task.FromResult(new ScriptResponse());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private string GetString(dynamic obj, string name)
|
|
44
|
+
{
|
|
45
|
+
if (obj == null) return null;
|
|
46
|
+
try
|
|
47
|
+
{
|
|
48
|
+
if (HasProperty(obj, name))
|
|
49
|
+
{
|
|
50
|
+
var v = GetPropertyValue(obj, name);
|
|
51
|
+
return v?.ToString();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch { }
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private object GetValue(dynamic obj, string name)
|
|
59
|
+
{
|
|
60
|
+
if (obj == null) return null;
|
|
61
|
+
try
|
|
62
|
+
{
|
|
63
|
+
if (HasProperty(obj, name))
|
|
64
|
+
return GetPropertyValue(obj, name);
|
|
65
|
+
}
|
|
66
|
+
catch { }
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Mapping for trigger-rezervation-video-call-update DirectTriggerTask (Type 12).
|
|
9
|
+
/// Triggers video-call-url-update transition on parent rezervation with videoCallUrl and InstanceData.
|
|
10
|
+
/// Parent key = roomName from subflow instance (passed from parent when subflow started).
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class TriggerRezervationVideoCallUpdateMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var triggerTask = task as DirectTriggerTask;
|
|
17
|
+
if (triggerTask == null)
|
|
18
|
+
throw new InvalidOperationException("Task must be a DirectTriggerTask");
|
|
19
|
+
|
|
20
|
+
var data = context.Instance?.Data;
|
|
21
|
+
var roomName = data?.roomName?.ToString()?.Trim();
|
|
22
|
+
var videoCallUrl = data?.videoCallUrl?.ToString()?.Trim();
|
|
23
|
+
var getTokenSuccess = data?.getTokenSuccess ?? false;
|
|
24
|
+
|
|
25
|
+
if (string.IsNullOrEmpty(roomName))
|
|
26
|
+
{
|
|
27
|
+
return Task.FromResult(new ScriptResponse
|
|
28
|
+
{
|
|
29
|
+
Data = new Dictionary<string, object>
|
|
30
|
+
{
|
|
31
|
+
{ "updateTriggered", false },
|
|
32
|
+
{ "reason", "missing-roomName" }
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var status = data?.status?.ToString()?.Trim();
|
|
38
|
+
var isStaff = status == "staff-enter";
|
|
39
|
+
var participantId = isStaff ? (data?.advisor?.ToString()?.Trim() ?? "advisor") : (data?.user?.ToString()?.Trim() ?? "user");
|
|
40
|
+
var videoCallUrlToAdd = new Dictionary<string, string> { { participantId, videoCallUrl ?? string.Empty } };
|
|
41
|
+
|
|
42
|
+
var body = new Dictionary<string, object>
|
|
43
|
+
{
|
|
44
|
+
{ "getTokenSuccess", getTokenSuccess },
|
|
45
|
+
{ "roomName", roomName },
|
|
46
|
+
{ "status", data?.status },
|
|
47
|
+
{ "videoCallUrlToAdd", videoCallUrlToAdd }
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
triggerTask.SetDomain("touch");
|
|
51
|
+
triggerTask.SetFlow("rezervation");
|
|
52
|
+
triggerTask.SetKey(roomName);
|
|
53
|
+
triggerTask.SetTransitionName("video-call-url-update");
|
|
54
|
+
triggerTask.SetBody(body);
|
|
55
|
+
|
|
56
|
+
return Task.FromResult(new ScriptResponse
|
|
57
|
+
{
|
|
58
|
+
Data = new Dictionary<string, object> { { "updateTriggered", true } }
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
63
|
+
{
|
|
64
|
+
return Task.FromResult(new ScriptResponse());
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Script Task (type 7) mapping for validate-date-for-rezervation.
|
|
8
|
+
/// Validates startDateTime and endDateTime from rezervation instance data.
|
|
9
|
+
/// Throws ArgumentException if date is in the past or invalid; otherwise returns success.
|
|
10
|
+
/// Runs before validate-slot-for-rezervation to avoid calling get-available-slots with invalid date.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class ValidateDateForRezervationMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var data = context.Instance?.Data;
|
|
17
|
+
if (data == null)
|
|
18
|
+
throw new InvalidOperationException("Instance data is required.");
|
|
19
|
+
|
|
20
|
+
var startDateTimeStr = GetString(data, "startDateTime");
|
|
21
|
+
var endDateTimeStr = GetString(data, "endDateTime");
|
|
22
|
+
if (string.IsNullOrEmpty(startDateTimeStr) || string.IsNullOrEmpty(endDateTimeStr))
|
|
23
|
+
throw new ArgumentException("startDateTime and endDateTime are required.", "date");
|
|
24
|
+
|
|
25
|
+
DateTime startDt;
|
|
26
|
+
if (!DateTime.TryParse(startDateTimeStr, out startDt))
|
|
27
|
+
throw new ArgumentException("Invalid startDateTime format.", "startDateTime");
|
|
28
|
+
DateTime endDt;
|
|
29
|
+
if (!DateTime.TryParse(endDateTimeStr, out endDt))
|
|
30
|
+
throw new ArgumentException("Invalid endDateTime format.", "endDateTime");
|
|
31
|
+
|
|
32
|
+
var now = DateTime.UtcNow;
|
|
33
|
+
if (startDt < now || endDt < now)
|
|
34
|
+
throw new ArgumentException("Date cannot be in the past.", "date");
|
|
35
|
+
if (endDt <= startDt)
|
|
36
|
+
throw new ArgumentException("endDateTime must be after startDateTime.", "date");
|
|
37
|
+
|
|
38
|
+
return Task.FromResult(new ScriptResponse());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
42
|
+
{
|
|
43
|
+
return Task.FromResult(new ScriptResponse());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private string GetString(dynamic obj, string name)
|
|
47
|
+
{
|
|
48
|
+
if (obj == null) return null;
|
|
49
|
+
try
|
|
50
|
+
{
|
|
51
|
+
if (HasProperty(obj, name))
|
|
52
|
+
{
|
|
53
|
+
var v = GetPropertyValue(obj, name);
|
|
54
|
+
return v?.ToString();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch { }
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|