@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,95 @@
|
|
|
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
|
+
|
|
8
|
+
/// <summary>
|
|
9
|
+
/// Mapping for execute-rez-chatroom-transfer DirectTriggerTask (Type 12).
|
|
10
|
+
/// Triggers the 'transfer' transition on a chat-room instance for the current item in rezChatRoomPlan.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class ExecuteRezChatRoomTransferMapping : 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
|
+
if (data == null)
|
|
22
|
+
throw new InvalidOperationException("Instance data is required");
|
|
23
|
+
|
|
24
|
+
var rezChatRoomPlan = data.rezChatRoomPlan;
|
|
25
|
+
if (rezChatRoomPlan == null)
|
|
26
|
+
return Task.FromResult(new ScriptResponse { Data = new { skipped = true, reason = "no-rezChatRoomPlan" } });
|
|
27
|
+
|
|
28
|
+
int processedIndex = 0;
|
|
29
|
+
if (HasProperty(data, "rezChatRoomProcessedIndex"))
|
|
30
|
+
int.TryParse(data.rezChatRoomProcessedIndex?.ToString() ?? "0", out processedIndex);
|
|
31
|
+
|
|
32
|
+
var items = rezChatRoomPlan as IEnumerable<object>;
|
|
33
|
+
if (items == null)
|
|
34
|
+
return Task.FromResult(new ScriptResponse { Data = new { skipped = true } });
|
|
35
|
+
|
|
36
|
+
var itemsList = items.ToList();
|
|
37
|
+
if (processedIndex >= itemsList.Count)
|
|
38
|
+
return Task.FromResult(new ScriptResponse { Data = new { skipped = true } });
|
|
39
|
+
|
|
40
|
+
dynamic currentItem = itemsList[processedIndex];
|
|
41
|
+
var chatRoomKey = currentItem?.chatRoomKey?.ToString();
|
|
42
|
+
var targetAdvisor = currentItem?.targetAdvisor?.ToString();
|
|
43
|
+
|
|
44
|
+
if (string.IsNullOrEmpty(chatRoomKey) || string.IsNullOrEmpty(targetAdvisor))
|
|
45
|
+
return Task.FromResult(new ScriptResponse { Data = new { skipped = true } });
|
|
46
|
+
|
|
47
|
+
triggerTask.SetDomain("touch");
|
|
48
|
+
triggerTask.SetFlow("chat-room");
|
|
49
|
+
triggerTask.SetKey(chatRoomKey);
|
|
50
|
+
triggerTask.SetTransitionName("transfer");
|
|
51
|
+
triggerTask.SetBody(new { newAdvisorId = targetAdvisor });
|
|
52
|
+
|
|
53
|
+
return Task.FromResult(new ScriptResponse());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
57
|
+
{
|
|
58
|
+
var data = context.Instance?.Data;
|
|
59
|
+
var success = context.Body?.isSuccess == true;
|
|
60
|
+
|
|
61
|
+
int processedIndex = 0;
|
|
62
|
+
if (data != null && HasProperty(data, "rezChatRoomProcessedIndex"))
|
|
63
|
+
int.TryParse(data.rezChatRoomProcessedIndex?.ToString() ?? "0", out processedIndex);
|
|
64
|
+
|
|
65
|
+
var result = new Dictionary<string, object>();
|
|
66
|
+
CopyIfPresent(result, data, "transferPlan");
|
|
67
|
+
CopyIfPresent(result, data, "validationResult");
|
|
68
|
+
CopyIfPresent(result, data, "sourceAdvisorId");
|
|
69
|
+
CopyIfPresent(result, data, "advisorType");
|
|
70
|
+
CopyIfPresent(result, data, "startDate");
|
|
71
|
+
CopyIfPresent(result, data, "endDate");
|
|
72
|
+
CopyIfPresent(result, data, "transferType");
|
|
73
|
+
CopyIfPresent(result, data, "enrichedRezervations");
|
|
74
|
+
CopyIfPresent(result, data, "processedIndex");
|
|
75
|
+
CopyIfPresent(result, data, "rezChatRoomPlan");
|
|
76
|
+
result["rezChatRoomProcessedIndex"] = processedIndex + 1;
|
|
77
|
+
result["lastRezChatRoomTransferSuccess"] = success;
|
|
78
|
+
|
|
79
|
+
return Task.FromResult(new ScriptResponse { Data = result });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
83
|
+
{
|
|
84
|
+
if (source == null) return;
|
|
85
|
+
try
|
|
86
|
+
{
|
|
87
|
+
if (HasProperty(source, name))
|
|
88
|
+
{
|
|
89
|
+
var v = GetPropertyValue(source, name);
|
|
90
|
+
if (v != null) target[name] = v;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch { }
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
|
|
8
|
+
/// <summary>
|
|
9
|
+
/// Mapping for execute-rezervation-transfer task (StartTask - Type 11).
|
|
10
|
+
/// Processes ONE transfer item at a time using processedIndex counter.
|
|
11
|
+
/// Each invocation starts a rezervation-update subflow instance for a single rezervation.
|
|
12
|
+
/// The self-loop pattern in validating state calls this repeatedly until all items are processed.
|
|
13
|
+
///
|
|
14
|
+
/// IMPORTANT: processedIndex increment happens in OutputHandler.
|
|
15
|
+
/// InputHandler MUST return non-null Data for StartTask to execute.
|
|
16
|
+
/// </summary>
|
|
17
|
+
public class ExecuteTransferMapping : ScriptBase, IMapping
|
|
18
|
+
{
|
|
19
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
20
|
+
{
|
|
21
|
+
var startTask = task as StartTask;
|
|
22
|
+
if (startTask == null)
|
|
23
|
+
throw new InvalidOperationException("Task must be a StartTask");
|
|
24
|
+
|
|
25
|
+
var data = context.Instance?.Data;
|
|
26
|
+
if (data == null)
|
|
27
|
+
throw new InvalidOperationException("Instance data is required");
|
|
28
|
+
|
|
29
|
+
var transferPlan = data.transferPlan;
|
|
30
|
+
if (transferPlan == null)
|
|
31
|
+
throw new ArgumentException("transferPlan is required.", "transferPlan");
|
|
32
|
+
|
|
33
|
+
var transferItems = transferPlan as IEnumerable<object>;
|
|
34
|
+
if (transferItems == null || !transferItems.Any())
|
|
35
|
+
return Task.FromResult(new ScriptResponse { Data = new { transferSkipped = true } });
|
|
36
|
+
|
|
37
|
+
int processedIndex = 0;
|
|
38
|
+
if (HasProperty(data, "processedIndex"))
|
|
39
|
+
{
|
|
40
|
+
int.TryParse(data.processedIndex?.ToString() ?? "0", out processedIndex);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var itemsList = transferItems.ToList();
|
|
44
|
+
if (processedIndex >= itemsList.Count)
|
|
45
|
+
return Task.FromResult(new ScriptResponse { Data = new { transferSkipped = true } });
|
|
46
|
+
|
|
47
|
+
dynamic currentItem = itemsList[processedIndex];
|
|
48
|
+
var rezervationKey = currentItem.rezervationKey?.ToString();
|
|
49
|
+
var targetAdvisor = currentItem.targetAdvisor?.ToString();
|
|
50
|
+
|
|
51
|
+
if (string.IsNullOrEmpty(rezervationKey) || string.IsNullOrEmpty(targetAdvisor))
|
|
52
|
+
return Task.FromResult(new ScriptResponse { Data = new { transferSkipped = true } });
|
|
53
|
+
|
|
54
|
+
var parentKey = context.Instance?.Key ?? DateTime.UtcNow.Ticks.ToString();
|
|
55
|
+
var instanceKey = CreateShortKey(parentKey, rezervationKey);
|
|
56
|
+
|
|
57
|
+
startTask.SetDomain("touch");
|
|
58
|
+
startTask.SetFlow("rezervation-update");
|
|
59
|
+
startTask.SetKey(instanceKey);
|
|
60
|
+
startTask.SetBody(new
|
|
61
|
+
{
|
|
62
|
+
randevuKey = rezervationKey,
|
|
63
|
+
targetAdvisor = targetAdvisor,
|
|
64
|
+
autoProcess = true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return Task.FromResult(new ScriptResponse
|
|
68
|
+
{
|
|
69
|
+
Data = new
|
|
70
|
+
{
|
|
71
|
+
processedIndex = processedIndex + 1,
|
|
72
|
+
currentTransferKey = rezervationKey,
|
|
73
|
+
currentTargetAdvisor = targetAdvisor
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
79
|
+
{
|
|
80
|
+
var success = context.Body?.isSuccess == true;
|
|
81
|
+
var data = context.Instance?.Data;
|
|
82
|
+
|
|
83
|
+
int processedIndex = 0;
|
|
84
|
+
if (data != null && HasProperty(data, "processedIndex"))
|
|
85
|
+
{
|
|
86
|
+
int.TryParse(data.processedIndex?.ToString() ?? "0", out processedIndex);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var transferPlan = data?.transferPlan;
|
|
90
|
+
string currentTransferKey = null;
|
|
91
|
+
string currentTargetAdvisor = null;
|
|
92
|
+
|
|
93
|
+
if (transferPlan != null)
|
|
94
|
+
{
|
|
95
|
+
var items = transferPlan as IEnumerable<object>;
|
|
96
|
+
if (items != null)
|
|
97
|
+
{
|
|
98
|
+
var itemsList = items.ToList();
|
|
99
|
+
if (processedIndex < itemsList.Count)
|
|
100
|
+
{
|
|
101
|
+
dynamic currentItem = itemsList[processedIndex];
|
|
102
|
+
currentTransferKey = currentItem?.rezervationKey?.ToString();
|
|
103
|
+
currentTargetAdvisor = currentItem?.targetAdvisor?.ToString();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var result = new Dictionary<string, object>();
|
|
109
|
+
CopyIfPresent(result, data, "transferPlan");
|
|
110
|
+
CopyIfPresent(result, data, "validationResult");
|
|
111
|
+
CopyIfPresent(result, data, "sourceAdvisorId");
|
|
112
|
+
CopyIfPresent(result, data, "advisorType");
|
|
113
|
+
CopyIfPresent(result, data, "startDate");
|
|
114
|
+
CopyIfPresent(result, data, "endDate");
|
|
115
|
+
CopyIfPresent(result, data, "transferType");
|
|
116
|
+
CopyIfPresent(result, data, "enrichedRezervations");
|
|
117
|
+
result["processedIndex"] = processedIndex + 1;
|
|
118
|
+
result["currentTransferKey"] = currentTransferKey;
|
|
119
|
+
result["currentTargetAdvisor"] = currentTargetAdvisor;
|
|
120
|
+
result["lastTransferSuccess"] = success;
|
|
121
|
+
result["lastTransferError"] = !success ? (context.Body?.errorMessage?.ToString() ?? "Transfer execution failed") : null;
|
|
122
|
+
|
|
123
|
+
return Task.FromResult(new ScriptResponse
|
|
124
|
+
{
|
|
125
|
+
Data = result
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// <summary>Creates a key <= 100 chars by truncating parentKey and rezervationKey.</summary>
|
|
130
|
+
private static string CreateShortKey(string parentKey, string rezervationKey)
|
|
131
|
+
{
|
|
132
|
+
var maxParent = 40;
|
|
133
|
+
var maxRez = 50;
|
|
134
|
+
var p = parentKey.Length <= maxParent ? parentKey : parentKey.Substring(parentKey.Length - maxParent);
|
|
135
|
+
var r = rezervationKey.Length <= maxRez ? rezervationKey : rezervationKey.Substring(rezervationKey.Length - maxRez);
|
|
136
|
+
return $"tu-{p}-{r}";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
140
|
+
{
|
|
141
|
+
if (source == null) return;
|
|
142
|
+
try
|
|
143
|
+
{
|
|
144
|
+
if (HasProperty(source, name))
|
|
145
|
+
{
|
|
146
|
+
var v = GetPropertyValue(source, name);
|
|
147
|
+
if (v != null) target[name] = v;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch { }
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
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 fetch-absence-entries-for-transfer task (DaprServiceTask - Type 3).
|
|
9
|
+
/// Queries all absence-entry instances (public holidays, working hours changes, personal leaves)
|
|
10
|
+
/// in complete state. OutputHandler stores them as absenceEntries in instance data.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class FetchAbsenceEntriesForTransferMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var serviceTask = task as DaprServiceTask;
|
|
17
|
+
if (serviceTask == null)
|
|
18
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
19
|
+
|
|
20
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
21
|
+
if (!string.IsNullOrEmpty(appId))
|
|
22
|
+
serviceTask.SetAppId(appId);
|
|
23
|
+
|
|
24
|
+
var filterJson =
|
|
25
|
+
"{\"and\":[" +
|
|
26
|
+
"{\"currentState\":{\"eq\":\"complete\"}}," +
|
|
27
|
+
"{\"or\":[" +
|
|
28
|
+
"{\"attributes\":{\"absenceType\":{\"eq\":\"public-holiday\"}}}," +
|
|
29
|
+
"{\"attributes\":{\"absenceType\":{\"eq\":\"working-hours-change\"}}}," +
|
|
30
|
+
"{\"attributes\":{\"absenceType\":{\"eq\":\"personal-leave\"}}}" +
|
|
31
|
+
"]}" +
|
|
32
|
+
"]}";
|
|
33
|
+
|
|
34
|
+
var queryParams = new List<string>
|
|
35
|
+
{
|
|
36
|
+
"pageSize=200",
|
|
37
|
+
"filter=" + filterJson
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
serviceTask.SetQueryString(string.Join("&", queryParams));
|
|
41
|
+
return Task.FromResult(new ScriptResponse());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
45
|
+
{
|
|
46
|
+
try
|
|
47
|
+
{
|
|
48
|
+
var body = context.Body;
|
|
49
|
+
var data = context.Instance?.Data;
|
|
50
|
+
|
|
51
|
+
if (body != null && body.isSuccess == false)
|
|
52
|
+
{
|
|
53
|
+
var errorMessage = body.errorMessage?.ToString() ?? "Failed to fetch absence entries";
|
|
54
|
+
throw new Exception(errorMessage);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var responseData = body?.data;
|
|
58
|
+
var items = responseData?.items;
|
|
59
|
+
|
|
60
|
+
var result = new Dictionary<string, object>();
|
|
61
|
+
CopyIfPresent(result, data, "sourceAdvisorId");
|
|
62
|
+
CopyIfPresent(result, data, "advisorType");
|
|
63
|
+
CopyIfPresent(result, data, "transferType");
|
|
64
|
+
CopyIfPresent(result, data, "startDate");
|
|
65
|
+
CopyIfPresent(result, data, "endDate");
|
|
66
|
+
CopyIfPresent(result, data, "rezervations");
|
|
67
|
+
CopyIfPresent(result, data, "allAdvisorKeys");
|
|
68
|
+
result["absenceEntries"] = items;
|
|
69
|
+
|
|
70
|
+
return Task.FromResult(new ScriptResponse
|
|
71
|
+
{
|
|
72
|
+
Data = result
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (Exception ex)
|
|
76
|
+
{
|
|
77
|
+
return Task.FromResult(new ScriptResponse
|
|
78
|
+
{
|
|
79
|
+
Data = new
|
|
80
|
+
{
|
|
81
|
+
error = "Failed to fetch absence entries for transfer",
|
|
82
|
+
errorDescription = ex.Message
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private string GetString(dynamic obj, string name)
|
|
89
|
+
{
|
|
90
|
+
if (obj == null) return null;
|
|
91
|
+
try
|
|
92
|
+
{
|
|
93
|
+
if (HasProperty(obj, name))
|
|
94
|
+
{
|
|
95
|
+
var v = GetPropertyValue(obj, name);
|
|
96
|
+
return v?.ToString();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch { }
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
104
|
+
{
|
|
105
|
+
if (source == null) return;
|
|
106
|
+
try
|
|
107
|
+
{
|
|
108
|
+
if (HasProperty(source, name))
|
|
109
|
+
{
|
|
110
|
+
var v = GetPropertyValue(source, name);
|
|
111
|
+
if (v != null) target[name] = v;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
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 fetch-advisors-for-transfer task (DaprServiceTask - Type 3).
|
|
9
|
+
/// Reads advisorType from instance data and queries all active advisor instances.
|
|
10
|
+
/// OutputHandler builds allAdvisorKeys list in {domain}.{advisorType}.{key} format.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class FetchAdvisorsForTransferMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var serviceTask = task as DaprServiceTask;
|
|
17
|
+
if (serviceTask == null)
|
|
18
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
19
|
+
|
|
20
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
21
|
+
if (!string.IsNullOrEmpty(appId))
|
|
22
|
+
serviceTask.SetAppId(appId);
|
|
23
|
+
|
|
24
|
+
var data = context.Instance?.Data;
|
|
25
|
+
if (data == null)
|
|
26
|
+
throw new InvalidOperationException("Instance data is required");
|
|
27
|
+
|
|
28
|
+
var advisorType = GetString(data, "advisorType");
|
|
29
|
+
if (string.IsNullOrEmpty(advisorType))
|
|
30
|
+
throw new ArgumentException("advisorType is required.", "advisorType");
|
|
31
|
+
|
|
32
|
+
serviceTask.SetMethodName($"api/v1/touch/workflows/{advisorType}/instances");
|
|
33
|
+
|
|
34
|
+
var conditions = new List<string>
|
|
35
|
+
{
|
|
36
|
+
"{\"or\":[" +
|
|
37
|
+
"{\"currentState\":{\"eq\":\"online\"}}," +
|
|
38
|
+
"{\"currentState\":{\"eq\":\"offline\"}}," +
|
|
39
|
+
"{\"currentState\":{\"eq\":\"busy\"}}," +
|
|
40
|
+
"{\"currentState\":{\"eq\":\"away\"}}" +
|
|
41
|
+
"]}",
|
|
42
|
+
"{\"status\":{\"eq\":\"A\"}}"
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var filterJson = "{\"and\":[" + string.Join(",", conditions) + "]}";
|
|
46
|
+
var queryParams = new List<string>
|
|
47
|
+
{
|
|
48
|
+
"pageSize=100",
|
|
49
|
+
"filter=" + filterJson
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
serviceTask.SetQueryString(string.Join("&", queryParams));
|
|
53
|
+
return Task.FromResult(new ScriptResponse());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
57
|
+
{
|
|
58
|
+
try
|
|
59
|
+
{
|
|
60
|
+
var body = context.Body;
|
|
61
|
+
var data = context.Instance?.Data;
|
|
62
|
+
|
|
63
|
+
if (body != null && body.isSuccess == false)
|
|
64
|
+
{
|
|
65
|
+
var errorMessage = body.errorMessage?.ToString() ?? "Failed to fetch advisors";
|
|
66
|
+
throw new Exception(errorMessage);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var advisorType = GetString(data, "advisorType");
|
|
70
|
+
var responseData = body?.data;
|
|
71
|
+
var items = responseData?.items;
|
|
72
|
+
|
|
73
|
+
var advisorKeys = new List<string>();
|
|
74
|
+
|
|
75
|
+
if (items != null)
|
|
76
|
+
{
|
|
77
|
+
foreach (var item in items)
|
|
78
|
+
{
|
|
79
|
+
if (item == null) continue;
|
|
80
|
+
var domain = GetString(item, "domain") ?? "touch";
|
|
81
|
+
var key = GetString(item, "key");
|
|
82
|
+
if (!string.IsNullOrEmpty(key))
|
|
83
|
+
{
|
|
84
|
+
var fullKey = key.Contains(".") ? key : $"{domain}.{advisorType}.{key}";
|
|
85
|
+
advisorKeys.Add(fullKey);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var result = new Dictionary<string, object>();
|
|
91
|
+
CopyIfPresent(result, data, "sourceAdvisorId");
|
|
92
|
+
CopyIfPresent(result, data, "advisorType");
|
|
93
|
+
CopyIfPresent(result, data, "transferType");
|
|
94
|
+
CopyIfPresent(result, data, "startDate");
|
|
95
|
+
CopyIfPresent(result, data, "endDate");
|
|
96
|
+
CopyIfPresent(result, data, "rezervations");
|
|
97
|
+
result["allAdvisorKeys"] = advisorKeys;
|
|
98
|
+
|
|
99
|
+
return Task.FromResult(new ScriptResponse
|
|
100
|
+
{
|
|
101
|
+
Data = result
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (Exception ex)
|
|
105
|
+
{
|
|
106
|
+
return Task.FromResult(new ScriptResponse
|
|
107
|
+
{
|
|
108
|
+
Data = new
|
|
109
|
+
{
|
|
110
|
+
error = "Failed to fetch advisors for transfer",
|
|
111
|
+
errorDescription = ex.Message
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private string GetString(dynamic obj, string name)
|
|
118
|
+
{
|
|
119
|
+
if (obj == null) return null;
|
|
120
|
+
try
|
|
121
|
+
{
|
|
122
|
+
if (HasProperty(obj, name))
|
|
123
|
+
{
|
|
124
|
+
var v = GetPropertyValue(obj, name);
|
|
125
|
+
return v?.ToString();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch { }
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
133
|
+
{
|
|
134
|
+
if (source == null) return;
|
|
135
|
+
try
|
|
136
|
+
{
|
|
137
|
+
if (HasProperty(source, name))
|
|
138
|
+
{
|
|
139
|
+
var v = GetPropertyValue(source, name);
|
|
140
|
+
if (v != null) target[name] = v;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch { }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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 fetch-permanent-chatrooms-for-transfer DaprServiceTask (Type 3).
|
|
9
|
+
/// InputHandler: queries chat-room instances where advisorId matches sourceAdvisorId and roomType != rezervation.
|
|
10
|
+
/// OutputHandler: stores the permanent rooms list for user selection.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class FetchPermanentChatRoomsMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
var serviceTask = task as DaprServiceTask;
|
|
17
|
+
if (serviceTask == null)
|
|
18
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
19
|
+
|
|
20
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
21
|
+
if (!string.IsNullOrEmpty(appId))
|
|
22
|
+
serviceTask.SetAppId(appId);
|
|
23
|
+
|
|
24
|
+
var data = context.Instance?.Data;
|
|
25
|
+
if (data == null)
|
|
26
|
+
throw new InvalidOperationException("Instance data is required");
|
|
27
|
+
|
|
28
|
+
var sourceAdvisorId = GetString(data, "sourceAdvisorId");
|
|
29
|
+
if (string.IsNullOrEmpty(sourceAdvisorId))
|
|
30
|
+
throw new ArgumentException("sourceAdvisorId is required.", "sourceAdvisorId");
|
|
31
|
+
|
|
32
|
+
var escapedAdvisor = sourceAdvisorId.Replace("\\", "\\\\").Replace("\"", "\\\"");
|
|
33
|
+
var filterParts = new List<string>
|
|
34
|
+
{
|
|
35
|
+
"{\"attributes\":{\"advisorId\":{\"eq\":\"" + escapedAdvisor + "\"}}}",
|
|
36
|
+
"{\"attributes\":{\"roomType\":{\"ne\":\"rezervation\"}}}",
|
|
37
|
+
"{\"or\":[{\"currentState\":{\"eq\":\"activated\"}},{\"currentState\":{\"eq\":\"deactivated\"}}]}"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var filterJson = "{\"and\":[" + string.Join(",", filterParts) + "]}";
|
|
41
|
+
var queryParams = new List<string>
|
|
42
|
+
{
|
|
43
|
+
"pageSize=100",
|
|
44
|
+
"filter=" + filterJson
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
serviceTask.SetQueryString(string.Join("&", queryParams));
|
|
48
|
+
return Task.FromResult(new ScriptResponse());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
52
|
+
{
|
|
53
|
+
var body = context.Body;
|
|
54
|
+
var data = context.Instance?.Data;
|
|
55
|
+
|
|
56
|
+
var responseData = body?.data;
|
|
57
|
+
var items = responseData?.items;
|
|
58
|
+
|
|
59
|
+
var permanentChatRooms = new List<object>();
|
|
60
|
+
|
|
61
|
+
if (items != null)
|
|
62
|
+
{
|
|
63
|
+
foreach (var item in items)
|
|
64
|
+
{
|
|
65
|
+
var key = GetString(item, "key");
|
|
66
|
+
var attrs = item?.attributes;
|
|
67
|
+
var user = attrs != null ? GetString(attrs, "user") : null;
|
|
68
|
+
var roomType = attrs != null ? GetString(attrs, "roomType") : null;
|
|
69
|
+
|
|
70
|
+
string roomId = null;
|
|
71
|
+
if (attrs != null && HasProperty(attrs, "chatIntegration") && attrs.chatIntegration != null)
|
|
72
|
+
roomId = GetString(attrs.chatIntegration, "roomId");
|
|
73
|
+
|
|
74
|
+
permanentChatRooms.Add(new Dictionary<string, object>
|
|
75
|
+
{
|
|
76
|
+
["chatRoomKey"] = key,
|
|
77
|
+
["user"] = user,
|
|
78
|
+
["roomType"] = roomType,
|
|
79
|
+
["roomId"] = roomId
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var result = new Dictionary<string, object>();
|
|
85
|
+
CopyIfPresent(result, data, "transferPlan");
|
|
86
|
+
CopyIfPresent(result, data, "validationResult");
|
|
87
|
+
CopyIfPresent(result, data, "sourceAdvisorId");
|
|
88
|
+
CopyIfPresent(result, data, "advisorType");
|
|
89
|
+
CopyIfPresent(result, data, "startDate");
|
|
90
|
+
CopyIfPresent(result, data, "endDate");
|
|
91
|
+
CopyIfPresent(result, data, "transferType");
|
|
92
|
+
CopyIfPresent(result, data, "enrichedRezervations");
|
|
93
|
+
CopyIfPresent(result, data, "rezChatRoomPlan");
|
|
94
|
+
CopyIfPresent(result, data, "rezChatRoomProcessedIndex");
|
|
95
|
+
result["permanentChatRooms"] = permanentChatRooms;
|
|
96
|
+
|
|
97
|
+
return Task.FromResult(new ScriptResponse { Data = result });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private string GetString(dynamic obj, string name)
|
|
101
|
+
{
|
|
102
|
+
if (obj == null) return null;
|
|
103
|
+
try
|
|
104
|
+
{
|
|
105
|
+
if (HasProperty(obj, name))
|
|
106
|
+
{
|
|
107
|
+
var v = GetPropertyValue(obj, name);
|
|
108
|
+
return v?.ToString();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch { }
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
116
|
+
{
|
|
117
|
+
if (source == null) return;
|
|
118
|
+
try
|
|
119
|
+
{
|
|
120
|
+
if (HasProperty(source, name))
|
|
121
|
+
{
|
|
122
|
+
var v = GetPropertyValue(source, name);
|
|
123
|
+
if (v != null) target[name] = v;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch { }
|
|
127
|
+
}
|
|
128
|
+
}
|