@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,65 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Condition for to-completed auto transition in create-rezervation-chat-rooms flow.
|
|
7
|
+
/// Rule: chatIntegration exists, no error, and required room IDs present
|
|
8
|
+
/// (portfolioManagerRoomId if portfolioManagerId was provided, investmentAdvisorRoomId if investmentAdvisorId was provided).
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class AllChatRoomsSuccessRule : ScriptBase, IConditionMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<bool> Handler(ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
try
|
|
15
|
+
{
|
|
16
|
+
if (context?.Instance?.Data == null)
|
|
17
|
+
return Task.FromResult(false);
|
|
18
|
+
|
|
19
|
+
var data = context.Instance.Data;
|
|
20
|
+
if (!HasProperty(data, "chatIntegration") || data.chatIntegration == null)
|
|
21
|
+
return Task.FromResult(false);
|
|
22
|
+
|
|
23
|
+
var chatIntegration = data.chatIntegration;
|
|
24
|
+
string error = GetString(chatIntegration, "error");
|
|
25
|
+
if (!string.IsNullOrWhiteSpace(error))
|
|
26
|
+
return Task.FromResult(false);
|
|
27
|
+
|
|
28
|
+
if (HasProperty(data, "portfolioManagerId") && !string.IsNullOrWhiteSpace(GetString(data, "portfolioManagerId")))
|
|
29
|
+
{
|
|
30
|
+
string pmRoomId = GetString(chatIntegration, "portfolioManagerRoomId");
|
|
31
|
+
if (string.IsNullOrWhiteSpace(pmRoomId))
|
|
32
|
+
return Task.FromResult(false);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (HasProperty(data, "investmentAdvisorId") && !string.IsNullOrWhiteSpace(GetString(data, "investmentAdvisorId")))
|
|
36
|
+
{
|
|
37
|
+
string iaRoomId = GetString(chatIntegration, "investmentAdvisorRoomId");
|
|
38
|
+
if (string.IsNullOrWhiteSpace(iaRoomId))
|
|
39
|
+
return Task.FromResult(false);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return Task.FromResult(true);
|
|
43
|
+
}
|
|
44
|
+
catch (Exception)
|
|
45
|
+
{
|
|
46
|
+
return Task.FromResult(false);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private string GetString(dynamic obj, string name)
|
|
51
|
+
{
|
|
52
|
+
if (obj == null) return null;
|
|
53
|
+
try
|
|
54
|
+
{
|
|
55
|
+
if (HasProperty(obj, name))
|
|
56
|
+
{
|
|
57
|
+
var v = GetPropertyValue(obj, name);
|
|
58
|
+
return v?.ToString();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
|
|
4
|
+
/// <summary>
|
|
5
|
+
/// Rule that always returns true. Used for auto-transitions that should always fire.
|
|
6
|
+
/// </summary>
|
|
7
|
+
public class AlwaysTrueRule : ScriptBase, IConditionMapping
|
|
8
|
+
{
|
|
9
|
+
public Task<bool> Handler(ScriptContext context)
|
|
10
|
+
{
|
|
11
|
+
return Task.FromResult(true);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Condition for to-failed auto transition in create-rezervation-chat-rooms flow.
|
|
7
|
+
/// Rule: opposite of AllChatRoomsSuccessRule (any step failed or required room IDs missing).
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class AnyChatRoomFailedRule : ScriptBase, IConditionMapping
|
|
10
|
+
{
|
|
11
|
+
public Task<bool> Handler(ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
try
|
|
14
|
+
{
|
|
15
|
+
if (context?.Instance?.Data == null)
|
|
16
|
+
return Task.FromResult(true);
|
|
17
|
+
|
|
18
|
+
var data = context.Instance.Data;
|
|
19
|
+
if (!HasProperty(data, "chatIntegration") || data.chatIntegration == null)
|
|
20
|
+
return Task.FromResult(true);
|
|
21
|
+
|
|
22
|
+
var chatIntegration = data.chatIntegration;
|
|
23
|
+
string error = GetString(chatIntegration, "error");
|
|
24
|
+
if (!string.IsNullOrWhiteSpace(error))
|
|
25
|
+
return Task.FromResult(true);
|
|
26
|
+
|
|
27
|
+
if (HasProperty(data, "portfolioManagerId") && !string.IsNullOrWhiteSpace(GetString(data, "portfolioManagerId")))
|
|
28
|
+
{
|
|
29
|
+
string pmRoomId = GetString(chatIntegration, "portfolioManagerRoomId");
|
|
30
|
+
if (string.IsNullOrWhiteSpace(pmRoomId))
|
|
31
|
+
return Task.FromResult(true);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (HasProperty(data, "investmentAdvisorId") && !string.IsNullOrWhiteSpace(GetString(data, "investmentAdvisorId")))
|
|
35
|
+
{
|
|
36
|
+
string iaRoomId = GetString(chatIntegration, "investmentAdvisorRoomId");
|
|
37
|
+
if (string.IsNullOrWhiteSpace(iaRoomId))
|
|
38
|
+
return Task.FromResult(true);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return Task.FromResult(false);
|
|
42
|
+
}
|
|
43
|
+
catch (Exception)
|
|
44
|
+
{
|
|
45
|
+
return Task.FromResult(true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private string GetString(dynamic obj, string name)
|
|
50
|
+
{
|
|
51
|
+
if (obj == null) return null;
|
|
52
|
+
try
|
|
53
|
+
{
|
|
54
|
+
if (HasProperty(obj, name))
|
|
55
|
+
{
|
|
56
|
+
var v = GetPropertyValue(obj, name);
|
|
57
|
+
return v?.ToString();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch { }
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Condition mapping for auto-validate transition in rezervation-update update-form state.
|
|
7
|
+
/// Returns true when autoProcess flag is set (transfer scenario).
|
|
8
|
+
/// Returns false for normal interactive flow (no autoProcess flag).
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class AutoProcessRule : ScriptBase, IConditionMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<bool> Handler(ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
try
|
|
15
|
+
{
|
|
16
|
+
if (context?.Instance?.Data == null)
|
|
17
|
+
return Task.FromResult(false);
|
|
18
|
+
|
|
19
|
+
var data = context.Instance.Data;
|
|
20
|
+
if (!HasProperty(data, "autoProcess"))
|
|
21
|
+
return Task.FromResult(false);
|
|
22
|
+
|
|
23
|
+
var val = data.autoProcess;
|
|
24
|
+
if (val == null)
|
|
25
|
+
return Task.FromResult(false);
|
|
26
|
+
|
|
27
|
+
if (val is bool boolVal)
|
|
28
|
+
return Task.FromResult(boolVal);
|
|
29
|
+
|
|
30
|
+
return Task.FromResult(val.ToString().Equals("true", StringComparison.OrdinalIgnoreCase)
|
|
31
|
+
|| val.ToString().Equals("True", StringComparison.OrdinalIgnoreCase));
|
|
32
|
+
}
|
|
33
|
+
catch (Exception)
|
|
34
|
+
{
|
|
35
|
+
return Task.FromResult(false);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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 fetch-rez-chatrooms-for-transfer DaprServiceTask (Type 3).
|
|
10
|
+
/// InputHandler: queries chat-room instances where advisorId matches sourceAdvisorId and roomType=rezervation.
|
|
11
|
+
/// OutputHandler: matches fetched rooms with transferPlan to build rezChatRoomPlan.
|
|
12
|
+
/// </summary>
|
|
13
|
+
public class BuildRezChatRoomPlanMapping : ScriptBase, IMapping
|
|
14
|
+
{
|
|
15
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
16
|
+
{
|
|
17
|
+
var serviceTask = task as DaprServiceTask;
|
|
18
|
+
if (serviceTask == null)
|
|
19
|
+
throw new InvalidOperationException("Task must be a DaprServiceTask");
|
|
20
|
+
|
|
21
|
+
var appId = GetConfigValue("DAPR_APP_ID");
|
|
22
|
+
if (!string.IsNullOrEmpty(appId))
|
|
23
|
+
serviceTask.SetAppId(appId);
|
|
24
|
+
|
|
25
|
+
var data = context.Instance?.Data;
|
|
26
|
+
if (data == null)
|
|
27
|
+
throw new InvalidOperationException("Instance data is required");
|
|
28
|
+
|
|
29
|
+
var sourceAdvisorId = GetString(data, "sourceAdvisorId");
|
|
30
|
+
if (string.IsNullOrEmpty(sourceAdvisorId))
|
|
31
|
+
throw new ArgumentException("sourceAdvisorId is required.", "sourceAdvisorId");
|
|
32
|
+
|
|
33
|
+
var escapedAdvisor = sourceAdvisorId.Replace("\\", "\\\\").Replace("\"", "\\\"");
|
|
34
|
+
var filterParts = new List<string>
|
|
35
|
+
{
|
|
36
|
+
"{\"attributes\":{\"advisorId\":{\"eq\":\"" + escapedAdvisor + "\"}}}",
|
|
37
|
+
"{\"attributes\":{\"roomType\":{\"eq\":\"rezervation\"}}}",
|
|
38
|
+
"{\"currentState\":{\"eq\":\"complete\"}}"
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var filterJson = "{\"and\":[" + string.Join(",", filterParts) + "]}";
|
|
42
|
+
var queryParams = new List<string>
|
|
43
|
+
{
|
|
44
|
+
"pageSize=100",
|
|
45
|
+
"filter=" + filterJson
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
serviceTask.SetQueryString(string.Join("&", queryParams));
|
|
49
|
+
return Task.FromResult(new ScriptResponse());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
53
|
+
{
|
|
54
|
+
var body = context.Body;
|
|
55
|
+
var data = context.Instance?.Data;
|
|
56
|
+
|
|
57
|
+
var responseData = body?.data;
|
|
58
|
+
var items = responseData?.items;
|
|
59
|
+
|
|
60
|
+
var transferPlan = data?.transferPlan;
|
|
61
|
+
var transferMap = new Dictionary<string, string>();
|
|
62
|
+
if (transferPlan != null)
|
|
63
|
+
{
|
|
64
|
+
foreach (var tp in transferPlan)
|
|
65
|
+
{
|
|
66
|
+
var rezKey = GetString(tp, "rezervationKey");
|
|
67
|
+
var targetAdvisor = GetString(tp, "targetAdvisor");
|
|
68
|
+
if (!string.IsNullOrEmpty(rezKey) && !string.IsNullOrEmpty(targetAdvisor))
|
|
69
|
+
transferMap[rezKey] = targetAdvisor;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var enrichedRezervations = data?.enrichedRezervations;
|
|
74
|
+
var userByRez = new Dictionary<string, string>();
|
|
75
|
+
if (enrichedRezervations != null)
|
|
76
|
+
{
|
|
77
|
+
foreach (var er in enrichedRezervations)
|
|
78
|
+
{
|
|
79
|
+
var key = GetString(er, "key");
|
|
80
|
+
var user = GetString(er, "user");
|
|
81
|
+
if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(user))
|
|
82
|
+
userByRez[key] = user;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var rezChatRoomPlan = new List<object>();
|
|
87
|
+
|
|
88
|
+
if (items != null)
|
|
89
|
+
{
|
|
90
|
+
foreach (var item in items)
|
|
91
|
+
{
|
|
92
|
+
var chatRoomKey = GetString(item, "key");
|
|
93
|
+
if (string.IsNullOrEmpty(chatRoomKey)) continue;
|
|
94
|
+
|
|
95
|
+
var attrs = item?.attributes;
|
|
96
|
+
if (attrs == null) continue;
|
|
97
|
+
|
|
98
|
+
var user = GetString(attrs, "user");
|
|
99
|
+
|
|
100
|
+
foreach (var kvp in transferMap)
|
|
101
|
+
{
|
|
102
|
+
if (userByRez.ContainsKey(kvp.Key) && userByRez[kvp.Key] == user)
|
|
103
|
+
{
|
|
104
|
+
rezChatRoomPlan.Add(new Dictionary<string, object>
|
|
105
|
+
{
|
|
106
|
+
["chatRoomKey"] = chatRoomKey,
|
|
107
|
+
["targetAdvisor"] = kvp.Value,
|
|
108
|
+
["rezervationKey"] = kvp.Key
|
|
109
|
+
});
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var result = new Dictionary<string, object>();
|
|
117
|
+
CopyIfPresent(result, data, "transferPlan");
|
|
118
|
+
CopyIfPresent(result, data, "validationResult");
|
|
119
|
+
CopyIfPresent(result, data, "sourceAdvisorId");
|
|
120
|
+
CopyIfPresent(result, data, "advisorType");
|
|
121
|
+
CopyIfPresent(result, data, "startDate");
|
|
122
|
+
CopyIfPresent(result, data, "endDate");
|
|
123
|
+
CopyIfPresent(result, data, "transferType");
|
|
124
|
+
CopyIfPresent(result, data, "enrichedRezervations");
|
|
125
|
+
CopyIfPresent(result, data, "processedIndex");
|
|
126
|
+
result["rezChatRoomPlan"] = rezChatRoomPlan;
|
|
127
|
+
result["rezChatRoomProcessedIndex"] = 0;
|
|
128
|
+
|
|
129
|
+
return Task.FromResult(new ScriptResponse { Data = result });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private string GetString(dynamic obj, string name)
|
|
133
|
+
{
|
|
134
|
+
if (obj == null) return null;
|
|
135
|
+
try
|
|
136
|
+
{
|
|
137
|
+
if (HasProperty(obj, name))
|
|
138
|
+
{
|
|
139
|
+
var v = GetPropertyValue(obj, name);
|
|
140
|
+
return v?.ToString();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch { }
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
148
|
+
{
|
|
149
|
+
if (source == null) return;
|
|
150
|
+
try
|
|
151
|
+
{
|
|
152
|
+
if (HasProperty(source, name))
|
|
153
|
+
{
|
|
154
|
+
var v = GetPropertyValue(source, name);
|
|
155
|
+
if (v != null) target[name] = v;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch { }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Timer mapping for can-start scheduled transition in rezervation active state.
|
|
7
|
+
/// Schedules the transition to fire 15 minutes before startDateTime.
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class CanStartRezervationTimerMapping : ScriptBase, ITimerMapping
|
|
10
|
+
{
|
|
11
|
+
public Task<TimerSchedule> Handler(ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
if (context?.Instance?.Data == null)
|
|
14
|
+
return Task.FromResult(TimerSchedule.FromDuration(TimeSpan.FromMinutes(1)));
|
|
15
|
+
|
|
16
|
+
var data = context.Instance.Data;
|
|
17
|
+
var startDateTimeStr = GetString(data, "startDateTime");
|
|
18
|
+
if (string.IsNullOrWhiteSpace(startDateTimeStr))
|
|
19
|
+
return Task.FromResult(TimerSchedule.FromDuration(TimeSpan.FromMinutes(1)));
|
|
20
|
+
|
|
21
|
+
if (!DateTime.TryParse(startDateTimeStr, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.RoundtripKind, out DateTime startDateTime))
|
|
22
|
+
return Task.FromResult(TimerSchedule.FromDuration(TimeSpan.FromMinutes(1)));
|
|
23
|
+
|
|
24
|
+
var targetTime = startDateTime.AddMinutes(-15);
|
|
25
|
+
var now = DateTime.UtcNow;
|
|
26
|
+
var duration = targetTime - now;
|
|
27
|
+
|
|
28
|
+
if (duration <= TimeSpan.Zero)
|
|
29
|
+
duration = TimeSpan.FromSeconds(1);
|
|
30
|
+
|
|
31
|
+
return Task.FromResult(TimerSchedule.FromDuration(duration));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private string GetString(dynamic obj, string name)
|
|
35
|
+
{
|
|
36
|
+
if (obj == null) return null;
|
|
37
|
+
try
|
|
38
|
+
{
|
|
39
|
+
if (HasProperty(obj, name))
|
|
40
|
+
{
|
|
41
|
+
var v = GetPropertyValue(obj, name);
|
|
42
|
+
return v?.ToString();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch { }
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
|
|
4
|
+
/// <summary>
|
|
5
|
+
/// Condition for check-time: state=active -> create-room-and-trigger.
|
|
6
|
+
/// </summary>
|
|
7
|
+
public class CanStartTransferMapping : ScriptBase, IConditionMapping
|
|
8
|
+
{
|
|
9
|
+
public Task<bool> Handler(ScriptContext context)
|
|
10
|
+
{
|
|
11
|
+
var absenceType = context.Instance?.Data?.absenceType?.ToString()?.Trim();
|
|
12
|
+
return Task.FromResult(absenceType == "personal-leave");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for cancel-absence-entry-for-rezervation DirectTriggerTask (Type 12).
|
|
8
|
+
/// Triggers cancel transition on the absence-entry instance when back-to-form, user-cancel, or advisor-cancel is executed.
|
|
9
|
+
/// Uses absenceEntryKey from instance (set in confirmation onEntry). No-op if absenceEntryKey is missing (e.g. old instances).
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class CancelAbsenceEntryForRezervationMapping : 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 absenceEntryKey = data?.absenceEntryKey?.ToString();
|
|
21
|
+
if (string.IsNullOrEmpty(absenceEntryKey))
|
|
22
|
+
{
|
|
23
|
+
return Task.FromResult(new ScriptResponse
|
|
24
|
+
{
|
|
25
|
+
Data = new { cancelTriggered = false, reason = "no-absence-entry-key" }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
triggerTask.SetDomain("touch");
|
|
30
|
+
triggerTask.SetFlow("absence-entry");
|
|
31
|
+
triggerTask.SetKey(absenceEntryKey);
|
|
32
|
+
triggerTask.SetTransitionName("cancel");
|
|
33
|
+
triggerTask.SetBody(new { });
|
|
34
|
+
|
|
35
|
+
return Task.FromResult(new ScriptResponse());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
39
|
+
{
|
|
40
|
+
var response = new ScriptResponse();
|
|
41
|
+
response.Data = new
|
|
42
|
+
{
|
|
43
|
+
cancelTriggered = context.Body?.isSuccess == true,
|
|
44
|
+
error = context.Body?.isSuccess == false ? (context.Body?.errorMessage ?? "Cancel failed") : null
|
|
45
|
+
};
|
|
46
|
+
return Task.FromResult(response);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for cancel-absence-entry-for-rezervation in randevu-update flow.
|
|
8
|
+
/// Triggers cancel on absence-entry using absenceEntryKey from instance.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class CancelAbsenceForRandevuUpdateMapping : 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 absenceEntryKey = GetString(data, "absenceEntryKey");
|
|
20
|
+
if (string.IsNullOrEmpty(absenceEntryKey))
|
|
21
|
+
{
|
|
22
|
+
return Task.FromResult(new ScriptResponse
|
|
23
|
+
{
|
|
24
|
+
Data = new { cancelTriggered = false, reason = "no-absence-entry-key" }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
triggerTask.SetDomain("touch");
|
|
29
|
+
triggerTask.SetFlow("absence-entry");
|
|
30
|
+
triggerTask.SetKey(absenceEntryKey);
|
|
31
|
+
triggerTask.SetTransitionName("cancel");
|
|
32
|
+
triggerTask.SetBody(new { });
|
|
33
|
+
|
|
34
|
+
return Task.FromResult(new ScriptResponse());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
38
|
+
{
|
|
39
|
+
var response = new ScriptResponse();
|
|
40
|
+
response.Data = new
|
|
41
|
+
{
|
|
42
|
+
cancelTriggered = context.Body?.isSuccess == true,
|
|
43
|
+
error = context.Body?.isSuccess == false ? (context.Body?.errorMessage ?? "Cancel failed") : null
|
|
44
|
+
};
|
|
45
|
+
return Task.FromResult(response);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private string GetString(dynamic obj, string name)
|
|
49
|
+
{
|
|
50
|
+
if (obj == null) return null;
|
|
51
|
+
try
|
|
52
|
+
{
|
|
53
|
+
if (HasProperty(obj, name))
|
|
54
|
+
{
|
|
55
|
+
var v = GetPropertyValue(obj, name);
|
|
56
|
+
return v?.ToString();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch { }
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Condition for to-failed auto transition in chat-room subflow.
|
|
7
|
+
/// Rule: opposite of ChatRoomCreatedSuccessRule (room creation failed or required data missing).
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class ChatRoomCreatedFailedRule : ScriptBase, IConditionMapping
|
|
10
|
+
{
|
|
11
|
+
public Task<bool> Handler(ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
try
|
|
14
|
+
{
|
|
15
|
+
if (context?.Instance?.Data == null)
|
|
16
|
+
return Task.FromResult(true);
|
|
17
|
+
|
|
18
|
+
var data = context.Instance.Data;
|
|
19
|
+
if (!HasProperty(data, "chatIntegration") || data.chatIntegration == null)
|
|
20
|
+
return Task.FromResult(true);
|
|
21
|
+
|
|
22
|
+
var chatIntegration = data.chatIntegration;
|
|
23
|
+
|
|
24
|
+
string error = GetString(chatIntegration, "error");
|
|
25
|
+
if (!string.IsNullOrWhiteSpace(error))
|
|
26
|
+
return Task.FromResult(true);
|
|
27
|
+
|
|
28
|
+
string roomId = GetString(chatIntegration, "roomId");
|
|
29
|
+
if (string.IsNullOrWhiteSpace(roomId))
|
|
30
|
+
return Task.FromResult(true);
|
|
31
|
+
|
|
32
|
+
return Task.FromResult(false);
|
|
33
|
+
}
|
|
34
|
+
catch (Exception)
|
|
35
|
+
{
|
|
36
|
+
return Task.FromResult(true);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private string GetString(dynamic obj, string name)
|
|
41
|
+
{
|
|
42
|
+
if (obj == null) return null;
|
|
43
|
+
try
|
|
44
|
+
{
|
|
45
|
+
if (HasProperty(obj, name))
|
|
46
|
+
{
|
|
47
|
+
var v = GetPropertyValue(obj, name);
|
|
48
|
+
return v?.ToString();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch { }
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Condition for to-complete auto transition in chat-room subflow.
|
|
7
|
+
/// Rule: chatIntegration exists, roomId present, no error.
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class ChatRoomCreatedSuccessRule : ScriptBase, IConditionMapping
|
|
10
|
+
{
|
|
11
|
+
public Task<bool> Handler(ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
try
|
|
14
|
+
{
|
|
15
|
+
if (context?.Instance?.Data == null)
|
|
16
|
+
return Task.FromResult(false);
|
|
17
|
+
|
|
18
|
+
var data = context.Instance.Data;
|
|
19
|
+
if (!HasProperty(data, "chatIntegration") || data.chatIntegration == null)
|
|
20
|
+
return Task.FromResult(false);
|
|
21
|
+
|
|
22
|
+
var chatIntegration = data.chatIntegration;
|
|
23
|
+
|
|
24
|
+
string error = GetString(chatIntegration, "error");
|
|
25
|
+
if (!string.IsNullOrWhiteSpace(error))
|
|
26
|
+
return Task.FromResult(false);
|
|
27
|
+
|
|
28
|
+
string roomId = GetString(chatIntegration, "roomId");
|
|
29
|
+
if (string.IsNullOrWhiteSpace(roomId))
|
|
30
|
+
return Task.FromResult(false);
|
|
31
|
+
|
|
32
|
+
return Task.FromResult(true);
|
|
33
|
+
}
|
|
34
|
+
catch (Exception)
|
|
35
|
+
{
|
|
36
|
+
return Task.FromResult(false);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private string GetString(dynamic obj, string name)
|
|
41
|
+
{
|
|
42
|
+
if (obj == null) return null;
|
|
43
|
+
try
|
|
44
|
+
{
|
|
45
|
+
if (HasProperty(obj, name))
|
|
46
|
+
{
|
|
47
|
+
var v = GetPropertyValue(obj, name);
|
|
48
|
+
return v?.ToString();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch { }
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|