private ActivityDO CloneActivity(ActivityDO source)
        {
            var clone = (ActivityDO)source.Clone();

            // for backward compatibility
            // if we have encrypted data decrypt it, otherwise leave CrateStorage as is
            if (source.EncryptedCrateStorage != null && source.EncryptedCrateStorage.Length != 0)
            {
                clone.CrateStorage = _encryptionService.DecryptString(source.Fr8AccountId, source.EncryptedCrateStorage);
                // get rid of encrypted data representation to save space in memory.
                clone.EncryptedCrateStorage = null;
            }

            return(clone);
        }
Пример #2
0
        public async Task <PayloadDTO> Run(IUnitOfWork uow, ActivityDO curActivityDO, ActivityExecutionMode curActionExecutionMode, ContainerDO curContainerDO)
        {
            if (curActivityDO == null)
            {
                throw new ArgumentNullException(nameof(curActivityDO));
            }

            //FR-2642 Logic to skip execution of activities with "SkipAtRunTime" Tag
            var template = _activityTemplate.GetByKey(curActivityDO.ActivityTemplateId);

            if (template.Tags != null && template.Tags.Contains("SkipAtRunTime", StringComparison.InvariantCultureIgnoreCase))
            {
                return(null);
            }

            EventManager.ActionStarted(curActivityDO, curContainerDO);

            // Explicitly extract authorization token to make AuthTokenDTO pass to activities.
            curActivityDO.AuthorizationToken = uow.AuthorizationTokenRepository.FindTokenById(curActivityDO.AuthorizationTokenId);

            try
            {
                IEnumerable <KeyValuePair <string, string> > parameters = null;

                if (curActionExecutionMode != ActivityExecutionMode.InitialRun)
                {
                    parameters = new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("scope", "childActivities")
                    };
                }

                if (curActionExecutionMode != ActivityExecutionMode.ReturnFromChildren)
                {
                    EventManager.ActivityRunRequested(curActivityDO, curContainerDO);
                }

                var activtiyClone = (ActivityDO)curActivityDO.Clone();

                using (var storage = _crateManager.UpdateStorage(() => activtiyClone.CrateStorage))
                {
                    var configurationControls = storage.CrateContentsOfType <StandardConfigurationControlsCM>().FirstOrDefault();

                    if (configurationControls != null)
                    {
                        var payloadStorage = _crateManager.GetStorage(curContainerDO.CrateStorage);
                        _upstreamDataExtractionService.ExtactAndAssignValues(configurationControls, payloadStorage);
                    }
                }

                var payloadDTO = await CallTerminalActivityAsync <PayloadDTO>(uow, "run", parameters, activtiyClone, curContainerDO.Id);

                EventManager.ActivityResponseReceived(curActivityDO, ActivityResponse.RequestSuspend);

                return(payloadDTO);
            }
            catch (Exception e)
            {
                ReportActivityInvocationError(curActivityDO, e.Message, curContainerDO.Id.ToString(), curActivityDO.Id.ToString(), EventManager.TerminalRunFailed);
                throw;
            }
        }